Class: Hitchart

Inherits:
Object
  • Object
show all
Defined in:
lib/hitchart.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHitchart

Returns a new instance of Hitchart.



8
9
10
# File 'lib/hitchart.rb', line 8

def initialize
  @hips = []
end

Instance Attribute Details

#gidObject

Returns the value of attribute gid.



5
6
7
# File 'lib/hitchart.rb', line 5

def gid
  @gid
end

#hipsObject

Returns the value of attribute hips.



5
6
7
# File 'lib/hitchart.rb', line 5

def hips
  @hips
end

Instance Method Details

#load_from_gid(gid) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hitchart.rb', line 13

def load_from_gid(gid)
  @gid = gid
  @xml_data = GamedayFetcher.fetch_inning_hit(gid)
  @xml_doc = REXML::Document.new(@xml_data)
  if @xml_doc.root
    @xml_doc.elements.each("hitchart/hip") do |element| 
      hip = Hip.new(element)
      @hips << hip
    end
  end
end