Module: MLB::Utils
- Defined in:
- lib/mlb/utils.rb
Overview
Utility methods and constants shared across the MLB gem
Constant Summary collapse
- DEFAULT_SPORT_ID =
Default sport ID for MLB (Major League Baseball)
1
Class Method Summary collapse
-
.build_query(params) ⇒ String
private
Builds a URL-encoded query string from parameters.
-
.current_season ⇒ Integer
Returns the current MLB season year.
-
.extract_id(object) ⇒ Integer, String
private
Extracts the ID from an object or returns the value as-is.
Class Method Details
.build_query(params) ⇒ String
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.
Builds a URL-encoded query string from parameters
40 41 42 |
# File 'lib/mlb/utils.rb', line 40 def build_query(params) URI.encode_www_form(params) end |
.current_season ⇒ Integer
Returns the current MLB season year
16 17 18 |
# File 'lib/mlb/utils.rb', line 16 def current_season Time.now.year end |
.extract_id(object) ⇒ Integer, String
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.
Extracts the ID from an object or returns the value as-is
29 30 31 |
# File 'lib/mlb/utils.rb', line 29 def extract_id(object) object.respond_to?(:id) ? object.id : object end |