Class: Shin::Play::Urplay
- Inherits:
-
Object
- Object
- Shin::Play::Urplay
- Defined in:
- lib/shin/play/urplay.rb
Defined Under Namespace
Instance Method Summary collapse
- #new ⇒ Object
-
#programs ⇒ Object
Programs.
Instance Method Details
#new ⇒ Object
7 8 9 |
# File 'lib/shin/play/urplay.rb', line 7 def new self end |
#programs ⇒ Object
Programs
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/shin/play/urplay.rb', line 12 def programs # Response response = Base.get('http://www.urplay.se/A-O') raise HTTPError, "The response didn't have a 200 HTTP Code. It had #{response.code}." unless response.code == 200 # Nokogiri parse @main_noko = Nokogiri::HTML response.body rescue nil if @main_noko != nil @array = [] @main_noko.css('section#alphabet > ul > li').map do |p| sluge = p.css('a')[0]['href'].strip.gsub("/Produkter/", '') p.css('a > span').remove titlee = p.css('a').text.strip ide = sluge[/^(\d+)/, 1] @array << {id: ide.to_i, slug: sluge, title: titlee} end @array.to_hashugar else raise NotValid, "Nokogiri failed to parse the HTML." end end |