Class: Backend::House
- Inherits:
-
Object
- Object
- Backend::House
- Defined in:
- lib/house_test/backend/house.rb
Overview
House in memory
Instance Attribute Summary collapse
-
#bathrooms ⇒ Object
Attributes of a house.
-
#garages ⇒ Object
Attributes of a house.
-
#id ⇒ Object
Attributes of a house.
-
#name ⇒ Object
Attributes of a house.
-
#rooms ⇒ Object
Attributes of a house.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(house_params) ⇒ House
constructor
Create a new house.
Constructor Details
#initialize(house_params) ⇒ House
Create a new house
9 10 11 12 13 14 15 16 17 |
# File 'lib/house_test/backend/house.rb', line 9 def initialize(house_params) params = IndifferentHash.new(house_params) self.name = params[:name] || Faker::Name.name self.rooms = (params[:rooms] || Faker::Number.number(digits: 1)).to_i self.garages = params[:garages] || 1 self.bathrooms = params[:bathrooms] || rooms - 1 self.id = SecureRandom.uuid end |
Instance Attribute Details
#bathrooms ⇒ Object
Attributes of a house
7 8 9 |
# File 'lib/house_test/backend/house.rb', line 7 def bathrooms @bathrooms end |
#garages ⇒ Object
Attributes of a house
7 8 9 |
# File 'lib/house_test/backend/house.rb', line 7 def garages @garages end |
#id ⇒ Object
Attributes of a house
7 8 9 |
# File 'lib/house_test/backend/house.rb', line 7 def id @id end |
#name ⇒ Object
Attributes of a house
7 8 9 |
# File 'lib/house_test/backend/house.rb', line 7 def name @name end |
#rooms ⇒ Object
Attributes of a house
7 8 9 |
# File 'lib/house_test/backend/house.rb', line 7 def rooms @rooms end |
Instance Method Details
#description ⇒ Object
20 21 22 |
# File 'lib/house_test/backend/house.rb', line 20 def description JSON.generate(id: id, name: name, rooms: rooms, bathrooms: bathrooms, garages: garages) end |