9. $ pry
[1] pry(main)> require 'nokogiri'
=> true
!
[2] pry(main)> require 'open-uri'
=> true
!
[3] pry(main)> doc = Nokogiri::HTML(open("http://en.wikipedia.org/wiki/
Ruby_(programming_language)"))
=> #(Document:0x3fe11d253454…)
!
[4] pry(main)> paragraph = doc.search('//*[@id="mw-content-text"]/p[23]').text
=> "Matsumoto has said that Ruby is designed for…”
!
[5] pry(main)> paragraph =~ /"([^"]*)/
=> 194
!
[6] pry(main)> $1
=> "I hope to see Ruby help every programmer in the world to be productive, and
to enjoy programming, and to be happy. That is the primary purpose of Ruby
language."
19. require “adhearsion”
class MyController < Adhearsion::CallController
def run
answer
resp = ask "How many woodchucks?", :limit => 1
say "You said #{resp}. That's obviously wrong!"
end
end
!
# adhearsion.com
20. require “artoo”
connection :sphero, adaptor: :sphero, port: '4560'
device :sphero, driver: :sphero
!
work do
every(3.seconds) do
puts "Rolling..."
sphero.roll 60, rand(360)
end
end
!
# artoo.io