Class: SportsDataApi::Mlb::Game
- Inherits:
-
Object
- Object
- SportsDataApi::Mlb::Game
- Defined in:
- lib/sports_data_api/mlb/game.rb
Instance Attribute Summary collapse
-
#away ⇒ Object
readonly
Returns the value of attribute away.
-
#away_team ⇒ Object
readonly
Returns the value of attribute away_team.
-
#broadcast ⇒ Object
readonly
Returns the value of attribute broadcast.
-
#clock ⇒ Object
readonly
Returns the value of attribute clock.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#home ⇒ Object
readonly
Returns the value of attribute home.
-
#home_team ⇒ Object
readonly
Returns the value of attribute home_team.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#quarter ⇒ Object
readonly
Returns the value of attribute quarter.
-
#rescheduled_from ⇒ Object
readonly
Returns the value of attribute rescheduled_from.
-
#rescheduled_reason ⇒ Object
readonly
Returns the value of attribute rescheduled_reason.
-
#scheduled ⇒ Object
readonly
Returns the value of attribute scheduled.
-
#season ⇒ Object
readonly
Returns the value of attribute season.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#venue ⇒ Object
readonly
Returns the value of attribute venue.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Game
constructor
A new instance of Game.
Constructor Details
#initialize(args = {}) ⇒ Game
Returns a new instance of Game.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sports_data_api/mlb/game.rb', line 8 def initialize(args={}) xml = args.fetch(:xml) @year = args[:year] ? args[:year].to_i : nil xml = xml.first if xml.is_a? Nokogiri::XML::NodeSet if xml.is_a? Nokogiri::XML::Element @id = xml['id'] @scheduled = Time.parse(xml.xpath('scheduled_start').children.first.to_s) @home = xml['home'] @away = xml['visitor'] @status = xml['status'] @venue = xml['venue'] @broadcast = Broadcast.new(xml.xpath('broadcast')) rescheduled_from = xml.xpath('rescheduled_from') if rescheduled_from.count > 0 @rescheduled_reason = rescheduled_from.first['reason'] @rescheduled_from = Time.parse(rescheduled_from.first.children.first.to_s) end end end |
Instance Attribute Details
#away ⇒ Object (readonly)
Returns the value of attribute away.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def away @away end |
#away_team ⇒ Object (readonly)
Returns the value of attribute away_team.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def away_team @away_team end |
#broadcast ⇒ Object (readonly)
Returns the value of attribute broadcast.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def broadcast @broadcast end |
#clock ⇒ Object (readonly)
Returns the value of attribute clock.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def clock @clock end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def date @date end |
#home ⇒ Object (readonly)
Returns the value of attribute home.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def home @home end |
#home_team ⇒ Object (readonly)
Returns the value of attribute home_team.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def home_team @home_team end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def id @id end |
#quarter ⇒ Object (readonly)
Returns the value of attribute quarter.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def quarter @quarter end |
#rescheduled_from ⇒ Object (readonly)
Returns the value of attribute rescheduled_from.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def rescheduled_from @rescheduled_from end |
#rescheduled_reason ⇒ Object (readonly)
Returns the value of attribute rescheduled_reason.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def rescheduled_reason @rescheduled_reason end |
#scheduled ⇒ Object (readonly)
Returns the value of attribute scheduled.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def scheduled @scheduled end |
#season ⇒ Object (readonly)
Returns the value of attribute season.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def season @season end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def status @status end |
#venue ⇒ Object (readonly)
Returns the value of attribute venue.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def venue @venue end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
4 5 6 |
# File 'lib/sports_data_api/mlb/game.rb', line 4 def year @year end |