Class: TepcoUsage
- Inherits:
-
Object
- Object
- TepcoUsage
- Defined in:
- lib/tepco_usage_api.rb
Constant Summary collapse
- @@default_options =
{ :proxy => nil }
Class Method Summary collapse
Instance Method Summary collapse
- #at(arg) ⇒ Object
- #in(arg) ⇒ Object
-
#initialize(options = {}) ⇒ TepcoUsage
constructor
A new instance of TepcoUsage.
- #latest ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TepcoUsage
Returns a new instance of TepcoUsage.
9 10 11 12 13 14 |
# File 'lib/tepco_usage_api.rb', line 9 def initialize( = {}) @options = @@default_options.merge(.inject({}) do |opts, (key, value)| opts[key.to_sym] = value opts end) end |
Class Method Details
.at(arg) ⇒ Object
67 68 69 |
# File 'lib/tepco_usage_api.rb', line 67 def at(arg) tepco.at(arg) end |
.in(arg) ⇒ Object
71 72 73 |
# File 'lib/tepco_usage_api.rb', line 71 def in(arg) tepco.in(arg) end |
.latest ⇒ Object
63 64 65 |
# File 'lib/tepco_usage_api.rb', line 63 def latest tepco.latest end |
Instance Method Details
#at(arg) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tepco_usage_api.rb', line 21 def at(arg) path = case arg when Date "/#{arg.year}/#{arg.month}/#{arg.day}.json" when Time "/#{arg.year}/#{arg.month}/#{arg.day}/#{arg.hour}.json" end response = request(path) JSON.parse(response.body) end |
#in(arg) ⇒ Object
32 33 34 35 36 |
# File 'lib/tepco_usage_api.rb', line 32 def in(arg) path = "/#{arg.year}/#{arg.month}.json" response = request(path) JSON.parse(response.body) end |
#latest ⇒ Object
16 17 18 19 |
# File 'lib/tepco_usage_api.rb', line 16 def latest response = request('/latest.json') JSON.parse(response.body) end |