Class: Building
- Inherits:
-
Object
- Object
- Building
- Defined in:
- lib/building.rb,
lib/building.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.
-
#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(input_options) ⇒ Object
Constructor Details
#initialize(input_options) ⇒ Building
Returns a new instance of Building.
5 6 7 8 9 10 11 12 |
# File 'lib/building.rb', line 5 def initialize() @name = ['name'] @address = ['address'] @height = ['height'] @id = ['id'] @construction_date = ['construction_date'] @architect = ['architect'] end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
3 4 5 |
# File 'lib/building.rb', line 3 def address @address end |
#architect ⇒ Object
Returns the value of attribute architect.
3 4 5 |
# File 'lib/building.rb', line 3 def architect @architect end |
#construction_date ⇒ Object
Returns the value of attribute construction_date.
3 4 5 |
# File 'lib/building.rb', line 3 def construction_date @construction_date end |
#height ⇒ Object
Returns the value of attribute height.
3 4 5 |
# File 'lib/building.rb', line 3 def height @height end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/building.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/building.rb', line 3 def name @name end |
Class Method Details
.all ⇒ Object
19 20 21 22 |
# File 'lib/building.rb', line 19 def self.all response = HTTP.get("http://localhost:3000/api/buildings/") response.parse.map { |building_hash| Building.new(building_hash) } end |
Instance Method Details
#destroy ⇒ Object
43 44 45 |
# File 'lib/building.rb', line 43 def destroy response = HTTP.delete("http://localhost:3000/api/buildings/#{@id}").parse end |
#update(input_options) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/building.rb', line 29 def update() response = HTTP.patch( "http://localhost:3000/api/buildings/#{@id}", form: ).parse @id = response['id'] @name = response['name'] @address = response['address'] @height = response['height'] @construction_date = response['construction_date'] @architect = response['architect'] @image = response['image'] end |