Class: FootballApi::Fixture
- Inherits:
-
BaseRequest
- Object
- BaseRequest
- FootballApi::Fixture
- Includes:
- Requestable
- Defined in:
- lib/football_api/fixture.rb
Constant Summary
Constants inherited from BaseRequest
Constants included from Symbolizer
Symbolizer::HASH_OR_ARRAY_KEYS
Class Attribute Summary collapse
-
.comp_id ⇒ Object
Returns the value of attribute comp_id.
-
.from_date ⇒ Object
Returns the value of attribute from_date.
-
.match_date ⇒ Object
Returns the value of attribute match_date.
-
.to_date ⇒ Object
Returns the value of attribute to_date.
Instance Attribute Summary collapse
-
#match ⇒ Object
Returns the value of attribute match.
-
#match_events ⇒ Object
Returns the value of attribute match_events.
-
#match_timer ⇒ Object
Returns the value of attribute match_timer.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Fixture
constructor
A new instance of Fixture.
- #parse_match(hash = {}) ⇒ Object
- #parse_match_events(arr = []) ⇒ Object
Methods included from Requestable
Methods inherited from BaseRequest
action_query, get!, get_parameters, response
Methods included from Symbolizer
Constructor Details
#initialize(hash = {}) ⇒ Fixture
Returns a new instance of Fixture.
30 31 32 33 34 |
# File 'lib/football_api/fixture.rb', line 30 def initialize(hash = {}) @match = parse_match(hash) @match_timer = hash[:match_timer] @match_events = parse_match_events(hash[:match_events]) end |
Class Attribute Details
.comp_id ⇒ Object
Returns the value of attribute comp_id.
8 9 10 |
# File 'lib/football_api/fixture.rb', line 8 def comp_id @comp_id end |
.from_date ⇒ Object
Returns the value of attribute from_date.
8 9 10 |
# File 'lib/football_api/fixture.rb', line 8 def from_date @from_date end |
.match_date ⇒ Object
Returns the value of attribute match_date.
8 9 10 |
# File 'lib/football_api/fixture.rb', line 8 def match_date @match_date end |
.to_date ⇒ Object
Returns the value of attribute to_date.
8 9 10 |
# File 'lib/football_api/fixture.rb', line 8 def to_date @to_date end |
Instance Attribute Details
#match ⇒ Object
Returns the value of attribute match.
28 29 30 |
# File 'lib/football_api/fixture.rb', line 28 def match @match end |
#match_events ⇒ Object
Returns the value of attribute match_events.
28 29 30 |
# File 'lib/football_api/fixture.rb', line 28 def match_events @match_events end |
#match_timer ⇒ Object
Returns the value of attribute match_timer.
28 29 30 |
# File 'lib/football_api/fixture.rb', line 28 def match_timer @match_timer end |
Class Method Details
.fixture_params ⇒ Object
21 22 23 24 25 |
# File 'lib/football_api/fixture.rb', line 21 def fixture_params [:comp_id, :match_date, :from_date, :to_date].each_with_object({}) do |symb, opts| opts.merge!(symb => send(symb) ) if send(symb) end end |
.where(options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/football_api/fixture.rb', line 10 def where( = {}) @comp_id = .delete(:comp_id) @match_date = .delete(:match_date) @from_date = .delete(:from_date) @to_date = .delete(:to_date) response.map{ |fixture| new (fixture) } end |
Instance Method Details
#parse_match(hash = {}) ⇒ Object
36 37 38 |
# File 'lib/football_api/fixture.rb', line 36 def parse_match(hash = {}) FootballApi::Match.new(hash) end |
#parse_match_events(arr = []) ⇒ Object
40 41 42 |
# File 'lib/football_api/fixture.rb', line 40 def parse_match_events(arr = []) Array(arr).map { |e| FootballApi::Event.new(e) } end |