Class: AhlScraper::Resource
- Inherits:
-
Object
- Object
- AhlScraper::Resource
show all
- Includes:
- Enumerable
- Defined in:
- lib/ahl_scraper/resource.rb
Direct Known Subclasses
Game, GameListItem, Games::Coach, Games::Events::Shot, Games::Goal, Games::Goalie, Games::Info, Games::OnIceSkater, Games::Overtime, Games::Penalty, Games::PenaltyShot, Games::Period, Games::Referee, Games::ShootoutAttempt, Games::Skater, Games::Star, Games::Team, GoalieGameListItem, Player, Players::DraftInfo, PlayoffBracket, PlayoffBrackets::Game, PlayoffBrackets::Round, PlayoffBrackets::Series, PlayoffBrackets::Team, RosterPlayer, Scoreboard, Scoreboards::Team, Season, SeasonListItem, Seasons::Team, SkaterGameListItem, TeamGameListItem, TeamListItem
Instance Method Summary
collapse
Constructor Details
#initialize(raw_data, opts = {}) ⇒ Resource
Returns a new instance of Resource.
7
8
9
10
|
# File 'lib/ahl_scraper/resource.rb', line 7
def initialize(raw_data, opts = {})
@raw_data = raw_data
@opts = opts
end
|
Instance Method Details
#[](key) ⇒ Object
22
23
24
|
# File 'lib/ahl_scraper/resource.rb', line 22
def [](key)
values[key.to_sym]
end
|
#each(&blk) ⇒ Object
34
35
36
|
# File 'lib/ahl_scraper/resource.rb', line 34
def each(&blk)
values.each(&blk)
end
|
#inspect ⇒ Object
18
19
20
|
# File 'lib/ahl_scraper/resource.rb', line 18
def inspect
"#<#{self.class.to_s.split('::').last}:0x#{object_id.to_s(16)} #{values}>"
end
|
#keys ⇒ Object
26
27
28
|
# File 'lib/ahl_scraper/resource.rb', line 26
def keys
values.keys
end
|
#to_json(*_opts) ⇒ Object
30
31
32
|
# File 'lib/ahl_scraper/resource.rb', line 30
def to_json(*_opts)
JSON.generate(values)
end
|
#values ⇒ Object
12
13
14
15
16
|
# File 'lib/ahl_scraper/resource.rb', line 12
def values
@values ||= (self.class.instance_methods(false) - %i[to_json inspect each keys [] values]).map do |m|
[m, send(m)]
end.to_h.transform_keys(&:to_sym)
end
|