Class: WorldbankAsDataframe::Data
- Inherits:
-
Object
- Object
- WorldbankAsDataframe::Data
- Extended by:
- Queriable
- Defined in:
- lib/worldbank_as_dataframe/data.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#others ⇒ Object
readonly
Returns the value of attribute others.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(values = {}) ⇒ Data
constructor
A new instance of Data.
- #to_h ⇒ Object
Methods included from Queriable
format, income_level, language, lending_type, most_recent_values, page, per_page, region
Constructor Details
#initialize(values = {}) ⇒ Data
Returns a new instance of Data.
28 29 30 31 32 33 34 35 36 |
# File 'lib/worldbank_as_dataframe/data.rb', line 28 def initialize(values={}) @raw = values @name = values['indicator'].delete('value') @id = values['indicator'].delete('id') @value = values.delete('value') @date = values.delete('date') values.delete('indicator') @others = values end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
6 7 8 |
# File 'lib/worldbank_as_dataframe/data.rb', line 6 def date @date end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/worldbank_as_dataframe/data.rb', line 6 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/worldbank_as_dataframe/data.rb', line 6 def name @name end |
#others ⇒ Object (readonly)
Returns the value of attribute others.
6 7 8 |
# File 'lib/worldbank_as_dataframe/data.rb', line 6 def others @others end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
6 7 8 |
# File 'lib/worldbank_as_dataframe/data.rb', line 6 def raw @raw end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/worldbank_as_dataframe/data.rb', line 6 def value @value end |
Class Method Details
.all ⇒ Object
20 21 22 |
# File 'lib/worldbank_as_dataframe/data.rb', line 20 def self.all find('all') end |
.country(arg) ⇒ Object
12 13 14 |
# File 'lib/worldbank_as_dataframe/data.rb', line 12 def self.country(arg) find('all').country(arg) end |
.fetch(arg) ⇒ Object
16 17 18 |
# File 'lib/worldbank_as_dataframe/data.rb', line 16 def self.fetch(arg) find(arg).fetch end |
.find(id) ⇒ Object
24 25 26 |
# File 'lib/worldbank_as_dataframe/data.rb', line 24 def self.find(id) WorldbankAsDataframe::DataQuery.new('indicator', id, self) end |
.raw ⇒ Object
8 9 10 |
# File 'lib/worldbank_as_dataframe/data.rb', line 8 def self.raw find('all').raw end |
Instance Method Details
#to_h ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/worldbank_as_dataframe/data.rb', line 38 def to_h hdr = @name suffix = nil suffix = " for #{@others['country']['value']}" rescue '' hdr += suffix {'Timestamps' => Date.new(@date.to_i, 12, 31), hdr => @value } end |