Class: FuzzyRealty::Listing
- Inherits:
-
Object
- Object
- FuzzyRealty::Listing
- Defined in:
- lib/classes.rb
Overview
Stub for testing without Rails project
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#location ⇒ Object
Returns the value of attribute location.
-
#price ⇒ Object
Returns the value of attribute price.
-
#sqft ⇒ Object
Returns the value of attribute sqft.
-
#style ⇒ Object
Returns the value of attribute style.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(values = {}) ⇒ Listing
constructor
A new instance of Listing.
Constructor Details
#initialize(values = {}) ⇒ Listing
Returns a new instance of Listing.
53 54 55 56 |
# File 'lib/classes.rb', line 53 def initialize(values={}) @@id ||=1 values.each_key {|k| instance_variable_set(:"@#{k}", values[k])} end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
52 53 54 |
# File 'lib/classes.rb', line 52 def id @id end |
#location ⇒ Object
Returns the value of attribute location.
52 53 54 |
# File 'lib/classes.rb', line 52 def location @location end |
#price ⇒ Object
Returns the value of attribute price.
52 53 54 |
# File 'lib/classes.rb', line 52 def price @price end |
#sqft ⇒ Object
Returns the value of attribute sqft.
52 53 54 |
# File 'lib/classes.rb', line 52 def sqft @sqft end |
#style ⇒ Object
Returns the value of attribute style.
52 53 54 |
# File 'lib/classes.rb', line 52 def style @style end |
Class Method Details
.random ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/classes.rb', line 57 def self.random FuzzyRealty::Listing.new({ :id => @@id += 1, :price => 20_000 + rand(250_000), :sqft => 300 + rand(2000), :location => %W{A B C D}[rand(4)], :style => %W{Bungalow Bi-level Split-level Two-story Condominium}[rand(5)] }) end |