Class: FootballApi::Competition
- Inherits:
-
BaseRequest
- Object
- BaseRequest
- FootballApi::Competition
- Includes:
- Requestable
- Defined in:
- lib/football_api/competition.rb
Constant Summary
Constants inherited from BaseRequest
Constants included from Symbolizer
Symbolizer::HASH_OR_ARRAY_KEYS
Instance Attribute Summary collapse
-
#id ⇒ Object
Response sample : [ { “id”:“1064”, “name”:“Superliga”, “region”:“Albania” } … ].
-
#name ⇒ Object
Response sample : [ { “id”:“1064”, “name”:“Superliga”, “region”:“Albania” } … ].
-
#region ⇒ Object
Response sample : [ { “id”:“1064”, “name”:“Superliga”, “region”:“Albania” } … ].
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Competition
constructor
A new instance of Competition.
Methods included from Requestable
Methods inherited from BaseRequest
action_query, get!, get_parameters, response
Methods included from Symbolizer
Constructor Details
#initialize(hash = {}) ⇒ Competition
Returns a new instance of Competition.
27 28 29 30 31 |
# File 'lib/football_api/competition.rb', line 27 def initialize(hash = {}) @id = hash[:id] @name = hash[:name] @region = hash[:region] end |
Instance Attribute Details
#id ⇒ Object
Response sample : [
{
"id":"1064",
"name":"Superliga",
"region":"Albania"
} ...
]
15 16 17 |
# File 'lib/football_api/competition.rb', line 15 def id @id end |
#name ⇒ Object
Response sample : [
{
"id":"1064",
"name":"Superliga",
"region":"Albania"
} ...
]
15 16 17 |
# File 'lib/football_api/competition.rb', line 15 def name @name end |
#region ⇒ Object
Response sample : [
{
"id":"1064",
"name":"Superliga",
"region":"Albania"
} ...
]
15 16 17 |
# File 'lib/football_api/competition.rb', line 15 def region @region end |
Class Method Details
.all ⇒ Object
17 18 19 20 21 |
# File 'lib/football_api/competition.rb', line 17 def self.all response && response.map do |comp| new(comp) end end |
.where(options = {}) ⇒ Object
23 24 25 |
# File 'lib/football_api/competition.rb', line 23 def self.where( = {}) response.select{ |c| (c, ) }.map{ |hsh| new(hsh) } end |