Class: FundraisingSummary
- Inherits:
-
Object
- Object
- FundraisingSummary
- Defined in:
- lib/congress_person.rb
Constant Summary collapse
- OPENS_FUNSUMMARY_MAP =
Maps specific set of FundraisingSummary attributes to OpenSecrets APIs. Mapping is structured “name of attr in CongressPerson object” => “name of hash key in result returned from API call”
{ "spent" => "spent", "total" => "total", "cash_on_hand" => "cash_on_hand", "debt" => "debt" }
Instance Attribute Summary collapse
-
#cash_on_hand ⇒ Object
readonly
Returns the value of attribute cash_on_hand.
-
#debt ⇒ Object
readonly
Returns the value of attribute debt.
-
#spent ⇒ Object
readonly
Returns the value of attribute spent.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize(init_hash) ⇒ FundraisingSummary
constructor
Given a hash of FundraisingSummary values from the OpenSecrets API, populate the corresponding instance variables in this instance.
Constructor Details
#initialize(init_hash) ⇒ FundraisingSummary
Given a hash of FundraisingSummary values from the OpenSecrets API, populate the corresponding instance variables in this instance.
164 165 166 167 168 169 |
# File 'lib/congress_person.rb', line 164 def initialize(init_hash) OPENS_FUNSUMMARY_MAP.each do |name, attribute| val = init_hash[attribute] instance_variable_set("@#{name}", val.to_i) end end |
Instance Attribute Details
#cash_on_hand ⇒ Object (readonly)
Returns the value of attribute cash_on_hand.
151 152 153 |
# File 'lib/congress_person.rb', line 151 def cash_on_hand @cash_on_hand end |
#debt ⇒ Object (readonly)
Returns the value of attribute debt.
151 152 153 |
# File 'lib/congress_person.rb', line 151 def debt @debt end |
#spent ⇒ Object (readonly)
Returns the value of attribute spent.
151 152 153 |
# File 'lib/congress_person.rb', line 151 def spent @spent end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
151 152 153 |
# File 'lib/congress_person.rb', line 151 def total @total end |