Skip to content

Instantly share code, notes, and snippets.

View dvoryankin's full-sized avatar
🌴
On vacation

Dvoryankin Dmitry dvoryankin

🌴
On vacation
View GitHub Profile
@dvoryankin
dvoryankin / bandit2.rb
Created September 4, 2016 13:44
one handed change result to one string
# encoding: cp866
money = 100
puts "\nЯ вижу у тебя есть #{money}$ и тебе не терпится их проиграть? Ну что же, начнём!"
1000.times do
puts
require "nokogiri"
# 1) What is your favorite Ruby class/library or method and why?
# 2) Given HTML: "<div class="images"><img src="/pic.jpg"></div>" Using Nokogiri how would you select the src attribute from
# the image? Show me two different ways to do that correctly the HTML given.
html = Nokogiri::HTML('<div class="images"><img src="/pic.jpg"></div>')
w1 = html.css('img')[0]['src'] # => "/pic.jpg"
w2 = html.xpath('//img/@src') # => "/pic.jpg"