Class: FuzzyRealty::Listing

Inherits:
Object
  • Object
show all
Defined in:
lib/classes.rb

Overview

Stub for testing without Rails project

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#idObject

Returns the value of attribute id.



52
53
54
# File 'lib/classes.rb', line 52

def id
  @id
end

#locationObject

Returns the value of attribute location.



52
53
54
# File 'lib/classes.rb', line 52

def location
  @location
end

#priceObject

Returns the value of attribute price.



52
53
54
# File 'lib/classes.rb', line 52

def price
  @price
end

#sqftObject

Returns the value of attribute sqft.



52
53
54
# File 'lib/classes.rb', line 52

def sqft
  @sqft
end

#styleObject

Returns the value of attribute style.



52
53
54
# File 'lib/classes.rb', line 52

def style
  @style
end

Class Method Details

.randomObject



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