class Building

Attributes

address[RW]
architect[RW]
construction_date[RW]
height[RW]
id[RW]
name[RW]

Public Class Methods

all() click to toggle source
# 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
create(building_info) click to toggle source
# File lib/building.rb, line 24
def self.create(building_info)
  response = HTTP.post("http://localhost:3000/api/buildings/", form: building_info)
  Building.new(response.parse)
end
find(input_id) click to toggle source
# File lib/building.rb, line 14
def self.find(input_id) 
  response = HTTP.get("http://localhost:3000/api/buildings/#{input_id}")
  Building.new(response.parse)
end
new(input_options) click to toggle source
# File lib/building.rb, line 5
def initialize(input_options)
  @name = input_options['name']
  @address  = input_options['address']
  @height = input_options['height']
  @id = input_options['id']
  @construction_date = input_options['construction_date']
  @architect = input_options['architect']
end

Public Instance Methods

destroy() click to toggle source
# File lib/building.rb, line 43
def destroy
  response = HTTP.delete("http://localhost:3000/api/buildings/#{@id}").parse 
end
update(input_options) click to toggle source
# File lib/building.rb, line 29
def update(input_options)
  response = HTTP.patch(
                        "http://localhost:3000/api/buildings/#{@id}",
                        form: input_options
                        ).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