Class: Building
- Inherits:
-
Object
- Object
- Building
- Defined in:
- lib/building_lookup.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#architect ⇒ Object
Returns the value of attribute architect.
-
#construction_date ⇒ Object
Returns the value of attribute construction_date.
-
#height ⇒ Object
Returns the value of attribute height.
-
#id ⇒ Object
Returns the value of attribute id.
-
#image ⇒ Object
Returns the value of attribute image.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(input_options) ⇒ Building
constructor
A new instance of Building.
- #update(building_params) ⇒ Object
Constructor Details
#initialize(input_options) ⇒ Building
Returns a new instance of Building.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/building_lookup.rb', line 7 def initialize() # add attributes here as instance variables @id = ['id'] @name = ['name'] @address = ['address'] @height = ['height'] @construction_date = ['construction_date'] @architect = ['architect'] @image = ['image'] end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
4 5 6 |
# File 'lib/building_lookup.rb', line 4 def address @address end |
#architect ⇒ Object
Returns the value of attribute architect.
4 5 6 |
# File 'lib/building_lookup.rb', line 4 def architect @architect end |
#construction_date ⇒ Object
Returns the value of attribute construction_date.
4 5 6 |
# File 'lib/building_lookup.rb', line 4 def construction_date @construction_date end |
#height ⇒ Object
Returns the value of attribute height.
4 5 6 |
# File 'lib/building_lookup.rb', line 4 def height @height end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/building_lookup.rb', line 4 def id @id end |
#image ⇒ Object
Returns the value of attribute image.
4 5 6 |
# File 'lib/building_lookup.rb', line 4 def image @image end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/building_lookup.rb', line 4 def name @name end |
Class Method Details
.all ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/building_lookup.rb', line 25 def self.all buildings = [] response = HTTP.get("http://localhost:3000/api/buildings") response.parse.each do |building| buildings << Building.new(building) end buildings end |
Instance Method Details
#destroy ⇒ Object
56 57 58 59 |
# File 'lib/building_lookup.rb', line 56 def destroy response = HTTP.delete("http://localhost:3000/api/buildings/#{@id}") end |
#update(building_params) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/building_lookup.rb', line 42 def update(building_params) response = HTTP.patch( "http://localhost:3000/api/buildings/#{@id}", form: building_params ) @id = response.parse['id'] @name = response.parse['name'] @address = response.parse['address'] @height = response.parse['height'] @construction_date = response.parse['construction_date'] @architect = response.parse['architect'] @image = response.parse['image'] end |