Class: FundraisingSummary

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_handObject (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

#debtObject (readonly)

Returns the value of attribute debt.



151
152
153
# File 'lib/congress_person.rb', line 151

def debt
  @debt
end

#spentObject (readonly)

Returns the value of attribute spent.



151
152
153
# File 'lib/congress_person.rb', line 151

def spent
  @spent
end

#totalObject (readonly)

Returns the value of attribute total.



151
152
153
# File 'lib/congress_person.rb', line 151

def total
  @total
end