Class: FootballApi::Fixture

Inherits:
BaseRequest show all
Includes:
Requestable
Defined in:
lib/football_api/fixture.rb

Constant Summary

Constants inherited from BaseRequest

BaseRequest::RETRIES

Constants included from Symbolizer

Symbolizer::HASH_OR_ARRAY_KEYS

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Requestable

included

Methods inherited from BaseRequest

action_query, get!, get_parameters, response

Methods included from Symbolizer

included

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_idObject

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_dateObject

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_dateObject

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_dateObject

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

#matchObject

Returns the value of attribute match.



28
29
30
# File 'lib/football_api/fixture.rb', line 28

def match
  @match
end

#match_eventsObject

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_timerObject

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_paramsObject



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(options = {})
  @comp_id = options.delete(:comp_id)
  @match_date = options.delete(:match_date)
  @from_date = options.delete(:from_date)
  @to_date = options.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