Class: Building
- Inherits:
-
Object
- Object
- Building
- Defined in:
- lib/poros_r_us.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.
6 7 8 9 10 11 12 13 |
# File 'lib/poros_r_us.rb', line 6 def initialize() @id = ["id"] @name = ["name"] @address = ["address"] @height = ["height"] @construction_date = ["construction_date"] @architect = ["architect"] end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
5 6 7 |
# File 'lib/poros_r_us.rb', line 5 def address @address end |
#architect ⇒ Object
Returns the value of attribute architect.
5 6 7 |
# File 'lib/poros_r_us.rb', line 5 def architect @architect end |
#construction_date ⇒ Object
Returns the value of attribute construction_date.
5 6 7 |
# File 'lib/poros_r_us.rb', line 5 def construction_date @construction_date end |
#height ⇒ Object
Returns the value of attribute height.
5 6 7 |
# File 'lib/poros_r_us.rb', line 5 def height @height end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/poros_r_us.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/poros_r_us.rb', line 5 def name @name end |
Class Method Details
.all ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/poros_r_us.rb', line 15 def self.all response = HTTP.get("http://localhost:3000/api/buildings") all_buildings_hash = response.parse all_buildings = [] all_buildings_hash.each do |building| all_buildings << Building.new(building) end all_buildings end |
.create(input_options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/poros_r_us.rb', line 25 def self.create() client_params = response = HTTP.post( "http://localhost:3000/api/buildings", form: client_params ) created_building = response.parse Building.new(created_building) end |
.edit(input_id) ⇒ Object
44 45 46 47 48 |
# File 'lib/poros_r_us.rb', line 44 def self.edit(input_id) response = HTTP.get("http://localhost:3000/api/buildings/#{input_id}") building_hash = response.parse render 'edit.html.erb' end |
Instance Method Details
#destroy ⇒ Object
62 63 64 |
# File 'lib/poros_r_us.rb', line 62 def destroy response = HTTP.delete("http://localhost:3000/api/buildings/#{id}") end |