Class: Catobills::FederalBody

Inherits:
Object
  • Object
show all
Defined in:
lib/catobills/federal_body.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ FederalBody

Returns a new instance of FederalBody.



6
7
8
9
10
# File 'lib/catobills/federal_body.rb', line 6

def initialize(params={})
  params.each_pair do |k,v|
    instance_variable_set("@#{k}", v)
  end
end

Instance Attribute Details

#abbrevObject (readonly)

Returns the value of attribute abbrev.



4
5
6
# File 'lib/catobills/federal_body.rb', line 4

def abbrev
  @abbrev
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/catobills/federal_body.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/catobills/federal_body.rb', line 4

def name
  @name
end

Class Method Details

.loadObject



12
13
14
15
16
17
# File 'lib/catobills/federal_body.rb', line 12

def self.load
  url = "http://dwillis.github.io/catobills/federal-bodies.json"
  response = HTTParty.get(url)
  bodies = Oj.load(response.body)
  bodies.map{|b| self.new( id: b['id'], name: b['name'], abbrev: b['abbrev'])}
end