Class: NpbFlash::Game
- Inherits:
-
Object
- Object
- NpbFlash::Game
- Defined in:
- lib/npb_flash/game.rb
Instance Attribute Summary collapse
-
#home ⇒ Object
Returns the value of attribute home.
-
#innings ⇒ Object
Returns the value of attribute innings.
-
#visitor ⇒ Object
Returns the value of attribute visitor.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id) ⇒ Game
constructor
A new instance of Game.
Constructor Details
#initialize(id) ⇒ Game
Returns a new instance of Game.
7 8 9 10 |
# File 'lib/npb_flash/game.rb', line 7 def initialize(id) @id = id @innings = [] end |
Instance Attribute Details
#home ⇒ Object
Returns the value of attribute home.
5 6 7 |
# File 'lib/npb_flash/game.rb', line 5 def home @home end |
#innings ⇒ Object
Returns the value of attribute innings.
5 6 7 |
# File 'lib/npb_flash/game.rb', line 5 def innings @innings end |
#visitor ⇒ Object
Returns the value of attribute visitor.
5 6 7 |
# File 'lib/npb_flash/game.rb', line 5 def visitor @visitor end |
Class Method Details
.from_node(node, id) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/npb_flash/game.rb', line 12 def self.from_node(node, id) game = Game.new(id) game.visitor, game.home = node.xpath('//div[@id="txt_ibd"]//table/tbody/tr[position() = 2 or position() = 3]/th/@class').map do |t| t.text end game.innings = node.xpath('//div[@id="txt_live"]//div[contains(concat(" ", @class, " "), " item ")]').map do |i| Inning::from_node(i) end game end |