Class: NHLStats::Division
- Inherits:
-
Object
- Object
- NHLStats::Division
- Defined in:
- lib/nhl_stats/division.rb
Instance Attribute Summary collapse
-
#abbreviation ⇒ Object
readonly
Returns the value of attribute abbreviation.
-
#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(division_data) ⇒ Division
constructor
A new instance of Division.
Constructor Details
#initialize(division_data) ⇒ Division
Returns a new instance of Division.
5 6 7 8 9 |
# File 'lib/nhl_stats/division.rb', line 5 def initialize(division_data) @id = division_data["id"] @name = division_data["name"] @abbreviation = division_data["nameShort"] end |
Instance Attribute Details
#abbreviation ⇒ Object (readonly)
Returns the value of attribute abbreviation.
3 4 5 |
# File 'lib/nhl_stats/division.rb', line 3 def abbreviation @abbreviation end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/nhl_stats/division.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/nhl_stats/division.rb', line 3 def name @name end |
Class Method Details
.find(id) ⇒ Object
11 12 13 14 15 |
# File 'lib/nhl_stats/division.rb', line 11 def self.find(id) response = Faraday.get("#{API_ROOT}/divisions/#{id}") attributes = JSON.parse(response.body).dig("divisions", 0) new(attributes) end |