Class: MLB::Collection Private
- Inherits:
-
Shale::Mapper
- Object
- Shale::Mapper
- MLB::Collection
- Defined in:
- lib/mlb/collection.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Base class for simple collection endpoints that only need an .all method. Provides a class macro to define the endpoint, item type, and attribute name, eliminating repetitive boilerplate across 20+ similar collection classes.
Direct Known Subclasses
BaseballStats, EventTypes, GameStatuses, GameTypes, HitTrajectories, JobTypes, Languages, LeagueLeaderTypes, LogicalEvents, Metrics, PitchCodes, PitchTypes, Platforms, Positions, ReviewReasons, RosterTypes, ScheduleEventTypes, SituationCodes, Skies, StandingsTypes, StatGroups, StatTypes, WindDirections
Class Attribute Summary collapse
-
.collection_name ⇒ Symbol
readonly
private
Returns the collection attribute name.
-
.endpoint ⇒ String
readonly
private
Returns the API endpoint for this collection.
Class Method Summary collapse
-
.all ⇒ Array
Retrieves all items from this collection.
-
.collection(endpoint:, item_type:, collection_name:) ⇒ void
private
Configures the collection with endpoint and item type.
Class Attribute Details
.collection_name ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the collection attribute name
21 22 23 |
# File 'lib/mlb/collection.rb', line 21 def collection_name @collection_name end |
.endpoint ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the API endpoint for this collection
15 16 17 |
# File 'lib/mlb/collection.rb', line 15 def endpoint @endpoint end |
Class Method Details
.all ⇒ Array
Retrieves all items from this collection
42 43 44 45 |
# File 'lib/mlb/collection.rb', line 42 def all response = CLIENT.get(endpoint) from_json("{\"#{collection_name}\":#{response}}").public_send(collection_name) end |
.collection(endpoint:, item_type:, collection_name:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Configures the collection with endpoint and item type
30 31 32 33 34 |
# File 'lib/mlb/collection.rb', line 30 def collection(endpoint:, item_type:, collection_name:) @endpoint = endpoint @collection_name = collection_name attribute collection_name, item_type, collection: true end |