Class: EiaFuel::Series
- Inherits:
-
Object
- Object
- EiaFuel::Series
- Defined in:
- lib/eia_fuel/series.rb
Instance Attribute Summary collapse
-
#copyright ⇒ Object
readonly
Returns the value of attribute copyright.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#end ⇒ Object
readonly
Returns the value of attribute end.
-
#frequency ⇒ Object
readonly
Returns the value of attribute frequency.
-
#geography ⇒ Object
readonly
Returns the value of attribute geography.
-
#iso3166 ⇒ Object
readonly
Returns the value of attribute iso3166.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#series_id ⇒ Object
readonly
Returns the value of attribute series_id.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#units ⇒ Object
readonly
Returns the value of attribute units.
-
#unitsshort ⇒ Object
readonly
Returns the value of attribute unitsshort.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Instance Method Summary collapse
-
#initialize(series = nil) ⇒ Series
constructor
A new instance of Series.
- #latest_price ⇒ Object
Constructor Details
#initialize(series = nil) ⇒ Series
Returns a new instance of Series.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/eia_fuel/series.rb', line 20 def initialize(series = nil) if series [:series_id, :name, :units, :frequency, :unitsshort, :description, :copyright, :source, :iso3166, :geography].each do |var| self.instance_variable_set "@#{var}", series[var.to_s] end @start = Date.strptime(series["end"], "%Y%m%d") @end = Date.strptime(series["end"], "%Y%m%d") @updated = Date.parse(series["updated"]) @data = generate_data(series["data"]) end end |
Instance Attribute Details
#copyright ⇒ Object (readonly)
Returns the value of attribute copyright.
11 12 13 |
# File 'lib/eia_fuel/series.rb', line 11 def copyright @copyright end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
18 19 20 |
# File 'lib/eia_fuel/series.rb', line 18 def data @data end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/eia_fuel/series.rb', line 10 def description @description end |
#end ⇒ Object (readonly)
Returns the value of attribute end.
16 17 18 |
# File 'lib/eia_fuel/series.rb', line 16 def end @end end |
#frequency ⇒ Object (readonly)
Returns the value of attribute frequency.
8 9 10 |
# File 'lib/eia_fuel/series.rb', line 8 def frequency @frequency end |
#geography ⇒ Object (readonly)
Returns the value of attribute geography.
14 15 16 |
# File 'lib/eia_fuel/series.rb', line 14 def geography @geography end |
#iso3166 ⇒ Object (readonly)
Returns the value of attribute iso3166.
13 14 15 |
# File 'lib/eia_fuel/series.rb', line 13 def iso3166 @iso3166 end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/eia_fuel/series.rb', line 6 def name @name end |
#series_id ⇒ Object (readonly)
Returns the value of attribute series_id.
5 6 7 |
# File 'lib/eia_fuel/series.rb', line 5 def series_id @series_id end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
12 13 14 |
# File 'lib/eia_fuel/series.rb', line 12 def source @source end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
15 16 17 |
# File 'lib/eia_fuel/series.rb', line 15 def start @start end |
#units ⇒ Object (readonly)
Returns the value of attribute units.
7 8 9 |
# File 'lib/eia_fuel/series.rb', line 7 def units @units end |
#unitsshort ⇒ Object (readonly)
Returns the value of attribute unitsshort.
9 10 11 |
# File 'lib/eia_fuel/series.rb', line 9 def unitsshort @unitsshort end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
17 18 19 |
# File 'lib/eia_fuel/series.rb', line 17 def updated @updated end |
Instance Method Details
#latest_price ⇒ Object
32 33 34 |
# File 'lib/eia_fuel/series.rb', line 32 def latest_price data.first.price end |