Class: PokelocParser::Parser
- Inherits:
-
Object
- Object
- PokelocParser::Parser
- Defined in:
- lib/pokeloc_parser/parser.rb
Instance Method Summary collapse
-
#initialize(id:) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
Instance Method Details
#parse ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pokeloc_parser/parser.rb', line 17 def parse uri = "http://blsetup.city.kyoto.jp/blsp/show.php?sid=#{@id}" doc = Nokogiri::HTML(URI.open(uri)) @result.station = doc.at_css('h1').content @result.got_at = doc.at_css('.bls-disp-time').content 5.times do |i| # ポケロケの行き先設定できる系統は現在最高5つまで。 div = doc.at_css("#ch#{i+1}") break if div.nil? approaching = get_alt(div.at_css('.bls-ap-img')) number = get_alt(div.at_css('.bls-keito-num-img')) destination = div.at_css('.bls-dest').content statuses = div.css('.busimg').map(&method(:get_alt)) @result.numbers << NumberResult.new( approaching: approaching, number: number, destination: destination, statuses: statuses, ) end @result end |