Class: Building
- Inherits:
-
Object
- Object
- Building
- Defined in:
- lib/building_rocksolid.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
- .all ⇒ Object
- .create(building_details) ⇒ Object
- .destroy(building_id) ⇒ Object
- .find(input_id) ⇒ Object
Instance Method Summary collapse
-
#initialize(input_options) ⇒ Building
constructor
A new instance of Building.
- #update(client_params) ⇒ Object
Constructor Details
#initialize(input_options) ⇒ Building
Returns a new instance of Building.
7 8 9 10 11 12 13 14 15 |
# File 'lib/building_rocksolid.rb', line 7 def initialize() # add attributes here as instance variables @name = ["name"] @address = ["address"] @height = ["height"] @construction_date = ["construction_date"] @architect = ["architect"] @id = ["id"] end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
6 7 8 |
# File 'lib/building_rocksolid.rb', line 6 def address @address end |
#architect ⇒ Object
Returns the value of attribute architect.
6 7 8 |
# File 'lib/building_rocksolid.rb', line 6 def architect @architect end |
#construction_date ⇒ Object
Returns the value of attribute construction_date.
6 7 8 |
# File 'lib/building_rocksolid.rb', line 6 def construction_date @construction_date end |
#height ⇒ Object
Returns the value of attribute height.
6 7 8 |
# File 'lib/building_rocksolid.rb', line 6 def height @height end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/building_rocksolid.rb', line 6 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/building_rocksolid.rb', line 6 def name @name end |
Class Method Details
.all ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/building_rocksolid.rb', line 17 def self.all response = HTTP.get("http://localhost:3000/api/buildings") buildings_details = response.parse buildings_details.map do |building_detail| Building.find(building_detail["id"]) end end |
.create(building_details) ⇒ Object
25 26 27 28 29 |
# File 'lib/building_rocksolid.rb', line 25 def self.create(building_details) response = HTTP.post("http://localhost:3000/api/buildings", form: building_details) building_details = response.parse Building.new(building_details) end |
.destroy(building_id) ⇒ Object
46 47 48 |
# File 'lib/building_rocksolid.rb', line 46 def self.destroy(building_id) response = HTTP.delete("http://localhost:3000/api/buildings/#{building_id}") end |
Instance Method Details
#update(client_params) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/building_rocksolid.rb', line 38 def update(client_params) response = HTTP.patch( "http://localhost:3000/api/buildings/#{id}", form: client_params ) end |