Class: NHLStats::Conference
- Inherits:
-
Object
- Object
- NHLStats::Conference
- Defined in:
- lib/nhl_stats/conference.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(conference_data) ⇒ Conference
constructor
A new instance of Conference.
Constructor Details
#initialize(conference_data) ⇒ Conference
Returns a new instance of Conference.
5 6 7 8 |
# File 'lib/nhl_stats/conference.rb', line 5 def initialize(conference_data) @id = conference_data["id"] @name = conference_data["name"] end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/nhl_stats/conference.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/nhl_stats/conference.rb', line 3 def name @name end |
Class Method Details
.find(id) ⇒ Object
10 11 12 13 14 |
# File 'lib/nhl_stats/conference.rb', line 10 def self.find(id) response = Faraday.get("#{API_ROOT}/conferences/#{id}") attributes = JSON.parse(response.body).dig("conferences", 0) new(attributes) end |
.list ⇒ Object
16 17 18 19 20 21 |
# File 'lib/nhl_stats/conference.rb', line 16 def self.list response = Faraday.get("#{API_ROOT}/conferences") JSON.parse(response.body). dig("conferences"). map { |c| NHLStats::Conference.new(c) } end |