Class: Listing
Constant Summary
collapse
- WORKFLOW_STATES =
%w(visible processing invisible expired)
- LEASE_STATES =
%w(listed leased)
- TYPES =
%w(lease sublease coworking_space)
- SPACE_TYPES =
%w(unit floor building)
- LEASE_TERMS =
['Full Service', 'NNN', 'Modified Gross']
- RATE_UNITS =
['/sqft/yr', '/sqft/mo', '/mo', '/yr', '/desk/mo']
- USES =
["Office", "Creative", "Loft", "Medical Office", "Flex Space", "R&D", "Office Showroom", "Industrial", "Retail"]
- SOURCE_TYPES =
%w(website flyer)
- CHANNELS =
%w(excavator mls staircase broker_dashboard)
Instance Method Summary
collapse
#avatar_url
#to_param
Instance Method Details
44
45
46
|
# File 'lib/mls/listing.rb', line 44
def contact
@contact ||= agents.first
end
|
#name ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/mls/listing.rb', line 112
def name
return read_attribute(:name) if read_attribute(:name)
case space_type
when 'unit'
if unit
"Unit #{unit}"
elsif floor
"#{floor.ordinalize} Floor Unit"
else
"Unit Lease"
end
when 'building'
"Entire Building"
when 'floor'
if floor
"#{floor.ordinalize} Floor"
elsif unit
"Unit #{unit}"
else
"Floor Lease"
end
end
end
|
#rate(units = nil) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/mls/listing.rb', line 49
def rate(units=nil)
return nil if !read_attribute(:rate)
units ||= rate_units
price = if rate_units == '/sqft/mo'
if units == '/sqft/mo'
read_attribute(:rate)
elsif units == '/sqft/yr'
read_attribute(:rate) * 12.0
elsif units == '/mo'
read_attribute(:rate) * size
elsif units == '/yr'
read_attribute(:rate) * size * 12.0
else
raise "Invalid rate conversion (#{rate_units} => #{units})"
end
elsif rate_units == '/sqft/yr'
if units == '/sqft/mo'
read_attribute(:rate) / 12.0
elsif units == '/sqft/yr'
read_attribute(:rate)
elsif units == '/mo'
(read_attribute(:rate) * size) / 12.0
elsif units == '/yr'
read_attribute(:rate) * size
else
raise "Invalid rate conversion (#{rate_units} => #{units})"
end
elsif rate_units == '/mo'
if units == '/sqft/mo'
read_attribute(:rate) / size.to_f
elsif units == '/sqft/yr'
(read_attribute(:rate) * 12) / size.to_f
elsif units == '/mo'
read_attribute(:rate)
elsif units == '/yr'
read_attribute(:rate) * 12
else
raise "Invalid rate conversion (#{rate_units} => #{units})"
end
elsif rate_units == '/yr'
if units == '/sqft/mo'
(read_attribute(:rate) / 12.0) / size.to_f
elsif units == '/sqft/yr'
read_attribute(:rate) / size.to_f
elsif units == '/mo'
read_attribute(:rate) / 12.0
elsif units == '/yr'
read_attribute(:rate)
else
raise "Invalid rate conversion (#{rate_units} => #{units})"
end
else
read_attribute(:rate)
end
price.round(2)
end
|