Class: Catobills::FederalBody
- Inherits:
-
Object
- Object
- Catobills::FederalBody
- Defined in:
- lib/catobills/federal_body.rb
Instance Attribute Summary collapse
-
#abbrev ⇒ Object
readonly
Returns the value of attribute abbrev.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ FederalBody
constructor
A new instance of FederalBody.
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
#abbrev ⇒ Object (readonly)
Returns the value of attribute abbrev.
4 5 6 |
# File 'lib/catobills/federal_body.rb', line 4 def abbrev @abbrev end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/catobills/federal_body.rb', line 4 def id @id end |
#name ⇒ Object (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
.load ⇒ Object
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 |