Module: Xmlstats
- Defined in:
- lib/xmlstats.rb,
lib/xmlstats/object.rb,
lib/xmlstats/version.rb,
lib/xmlstats/endpoint.rb,
lib/xmlstats/cachers/redis.rb,
lib/xmlstats/cachers/memory.rb,
lib/xmlstats/http_getters/net_http.rb
Defined Under Namespace
Modules: Cachers, Endpoint, Endpoints, HttpGetters, Objects Classes: Object
Constant Summary collapse
- VERSION =
"1.7.0"
Class Method Summary collapse
-
.api_key ⇒ Object
Manage api key.
- .api_key=(api_key) ⇒ Object
-
.cacher ⇒ Object
Manage cacher.
- .cacher=(cacher) ⇒ Object
-
.contact_info ⇒ Object
Manage contact info.
- .contact_info=(contact_info) ⇒ Object
-
.events(*args) ⇒ Object
Wrapper methods to each endpoint.
-
.http_getter ⇒ Object
Manage http getter.
- .http_getter=(http_getter) ⇒ Object
- .limit_remaining ⇒ Object
- .limit_remaining=(count) ⇒ Object
- .limit_reset_time ⇒ Object
- .limit_reset_time=(time) ⇒ Object
-
.limit_total ⇒ Object
Methods to retrieve current rate limit status.
- .limit_total=(count) ⇒ Object
- .mlb_box_score(*args) ⇒ Object
- .mlb_roster(*args) ⇒ Object
- .mlb_standing(*args) ⇒ Object
- .mlb_team_results(*args) ⇒ Object
- .mlb_teams(*args) ⇒ Object
- .mlb_wild_card_standing(*args) ⇒ Object
- .nba_box_score(*args) ⇒ Object
- .nba_leaders(*args) ⇒ Object
- .nba_roster(*args) ⇒ Object
- .nba_standing(*args) ⇒ Object
- .nba_team_results(*args) ⇒ Object
- .nba_teams(*args) ⇒ Object
Class Method Details
.api_key ⇒ Object
Manage api key
51 52 53 |
# File 'lib/xmlstats.rb', line 51 def api_key @api_key ||= ENV["XMLSTATS_API_KEY"] end |
.api_key=(api_key) ⇒ Object
55 56 57 |
# File 'lib/xmlstats.rb', line 55 def api_key= api_key @api_key = api_key end |
.cacher ⇒ Object
Manage cacher
83 84 85 |
# File 'lib/xmlstats.rb', line 83 def cacher @cacher ||= Xmlstats::Cachers::Memory.new end |
.cacher=(cacher) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/xmlstats.rb', line 87 def cacher= cacher case cacher.class.name when "Redis" then @cacher = Xmlstats::Cachers::Redis.new(cacher) else @cacher = cacher end end |
.contact_info ⇒ Object
Manage contact info
61 62 63 64 65 |
# File 'lib/xmlstats.rb', line 61 def contact_info error = "specify user-agent contact info with: Xmlstats.contact_info = '[email protected]'" @contact_info ||= ENV["XMLSTATS_CONTACT_INFO"] @contact_info or raise(error) end |
.contact_info=(contact_info) ⇒ Object
67 68 69 |
# File 'lib/xmlstats.rb', line 67 def contact_info= contact_info @contact_info = contact_info end |
.events(*args) ⇒ Object
Wrapper methods to each endpoint
126 127 128 |
# File 'lib/xmlstats.rb', line 126 def events *args Xmlstats::Endpoints::Events.fetch *args end |
.http_getter ⇒ Object
Manage http getter
73 74 75 |
# File 'lib/xmlstats.rb', line 73 def http_getter @http_getter ||= Xmlstats::HttpGetters::NetHttp.new end |
.http_getter=(http_getter) ⇒ Object
77 78 79 |
# File 'lib/xmlstats.rb', line 77 def http_getter= http_getter @http_getter = http_getter end |
.limit_remaining ⇒ Object
104 105 106 |
# File 'lib/xmlstats.rb', line 104 def limit_remaining (cacher.get("rate_limit.limit_remaining") || 6).to_i end |
.limit_remaining=(count) ⇒ Object
108 109 110 |
# File 'lib/xmlstats.rb', line 108 def limit_remaining=(count) cacher.set("rate_limit.limit_remaining", count) end |
.limit_reset_time ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/xmlstats.rb', line 112 def limit_reset_time if ( reset_time = cacher.get("rate_limit.limit_reset_time") ) Time.parse(reset_time) else Time.now end end |
.limit_reset_time=(time) ⇒ Object
120 121 122 |
# File 'lib/xmlstats.rb', line 120 def limit_reset_time=(time) cacher.set("rate_limit.limit_reset_time", time.iso8601) end |
.limit_total ⇒ Object
Methods to retrieve current rate limit status
96 97 98 |
# File 'lib/xmlstats.rb', line 96 def limit_total (cacher.get("rate_limit.limit_total") || 6).to_i end |
.limit_total=(count) ⇒ Object
100 101 102 |
# File 'lib/xmlstats.rb', line 100 def limit_total=(count) cacher.set("rate_limit.limit_total", count) end |
.mlb_box_score(*args) ⇒ Object
130 131 132 |
# File 'lib/xmlstats.rb', line 130 def mlb_box_score *args Xmlstats::Endpoints::MlbBoxScore.fetch *args end |
.mlb_roster(*args) ⇒ Object
174 175 176 |
# File 'lib/xmlstats.rb', line 174 def mlb_roster *args Xmlstats::Endpoints::MlbRoster.fetch *args end |
.mlb_standing(*args) ⇒ Object
138 139 140 |
# File 'lib/xmlstats.rb', line 138 def mlb_standing *args Xmlstats::Endpoints::MlbStanding.fetch *args end |
.mlb_team_results(*args) ⇒ Object
150 151 152 |
# File 'lib/xmlstats.rb', line 150 def mlb_team_results *args Xmlstats::Endpoints::MlbTeamResults.fetch *args end |
.mlb_teams(*args) ⇒ Object
158 159 160 |
# File 'lib/xmlstats.rb', line 158 def mlb_teams *args Xmlstats::Endpoints::MlbTeams.fetch *args end |
.mlb_wild_card_standing(*args) ⇒ Object
146 147 148 |
# File 'lib/xmlstats.rb', line 146 def mlb_wild_card_standing *args Xmlstats::Endpoints::MlbWildCardStanding.fetch *args end |
.nba_box_score(*args) ⇒ Object
134 135 136 |
# File 'lib/xmlstats.rb', line 134 def nba_box_score *args Xmlstats::Endpoints::NbaBoxScore.fetch *args end |
.nba_leaders(*args) ⇒ Object
166 167 168 |
# File 'lib/xmlstats.rb', line 166 def nba_leaders *args Xmlstats::Endpoints::NbaLeaders.fetch *args end |
.nba_roster(*args) ⇒ Object
170 171 172 |
# File 'lib/xmlstats.rb', line 170 def nba_roster *args Xmlstats::Endpoints::NbaRoster.fetch *args end |
.nba_standing(*args) ⇒ Object
142 143 144 |
# File 'lib/xmlstats.rb', line 142 def nba_standing *args Xmlstats::Endpoints::NbaStanding.fetch *args end |
.nba_team_results(*args) ⇒ Object
154 155 156 |
# File 'lib/xmlstats.rb', line 154 def nba_team_results *args Xmlstats::Endpoints::NbaTeamResults.fetch *args end |