mls 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mls/models/listing.rb +4 -3
- data/mls.gemspec +1 -1
- data/test/units/models/test_listing.rb +7 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29b32b14a88b40ef3ba7e052b0b7879440e83082
|
4
|
+
data.tar.gz: 3301c63391f4d2d263d52de6365e2dd5b3263f12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b93870aca8be84585b43c4a84770727d4e1f304ffa77bce61cc38733c5948b70a58097960d99dc109be9a4e0e81b3eec168be9c087d855e7cf70f6f633afeee
|
7
|
+
data.tar.gz: 534c1c533e91a10735594c4fa41ce3c479d051fec9079de033f63e878ac6348b61a6b31d393447dd751b937e90dc8fea7c3eabd4126d9f8d0a3cff5b8be5aaa3
|
data/lib/mls/models/listing.rb
CHANGED
@@ -153,9 +153,10 @@ class MLS::Listing < MLS::Resource
|
|
153
153
|
end
|
154
154
|
|
155
155
|
# TODO: remove /desk/mo conversions
|
156
|
-
def rate(units=
|
156
|
+
def rate(units=nil)
|
157
157
|
return nil if !@rate
|
158
|
-
|
158
|
+
units ||= rate_units
|
159
|
+
|
159
160
|
price = if rate_units == '/sqft/mo'
|
160
161
|
if units == '/sqft/mo'
|
161
162
|
@rate
|
@@ -220,7 +221,7 @@ class MLS::Listing < MLS::Resource
|
|
220
221
|
if units == '/sqft/mo'
|
221
222
|
@rate / 200.0
|
222
223
|
elsif units == '/sqft/yr'
|
223
|
-
(
|
224
|
+
(@rate * 12) / 200.0
|
224
225
|
elsif units == '/mo'
|
225
226
|
@rate
|
226
227
|
elsif units == '/yr'
|
data/mls.gemspec
CHANGED
@@ -194,7 +194,7 @@ class TestListing < ::Test::Unit::TestCase
|
|
194
194
|
def test_rate_per_sqft_per_year
|
195
195
|
listing = MLS::Listing.new(:rate => 126, :rate_units => '/sqft/yr', :size => 5)
|
196
196
|
|
197
|
-
assert_equal
|
197
|
+
assert_equal 126, listing.rate
|
198
198
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
199
199
|
assert_equal 126, listing.rate('/sqft/yr')
|
200
200
|
assert_equal 52.5, listing.rate('/mo')
|
@@ -208,7 +208,7 @@ class TestListing < ::Test::Unit::TestCase
|
|
208
208
|
def test_rate_per_month
|
209
209
|
listing = MLS::Listing.new(:rate => 52.5, :rate_units => '/mo', :size => 5)
|
210
210
|
|
211
|
-
assert_equal
|
211
|
+
assert_equal 52.5, listing.rate
|
212
212
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
213
213
|
assert_equal 126, listing.rate('/sqft/yr')
|
214
214
|
assert_equal 52.5, listing.rate('/mo')
|
@@ -222,7 +222,7 @@ class TestListing < ::Test::Unit::TestCase
|
|
222
222
|
def test_rate_per_year
|
223
223
|
listing = MLS::Listing.new(:rate => 630, :rate_units => '/yr', :size => 5)
|
224
224
|
|
225
|
-
assert_equal
|
225
|
+
assert_equal 630, listing.rate
|
226
226
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
227
227
|
assert_equal 126, listing.rate('/sqft/yr')
|
228
228
|
assert_equal 52.5, listing.rate('/mo')
|
@@ -234,13 +234,13 @@ class TestListing < ::Test::Unit::TestCase
|
|
234
234
|
end
|
235
235
|
|
236
236
|
def test_rate_per_desk_per_month
|
237
|
-
listing = MLS::Listing.new(:rate =>
|
237
|
+
listing = MLS::Listing.new(:rate => 2100, :rate_units => '/desk/mo', :size => 5)
|
238
238
|
|
239
|
-
assert_equal
|
239
|
+
assert_equal 2100, listing.rate
|
240
240
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
241
241
|
assert_equal 126, listing.rate('/sqft/yr')
|
242
|
-
assert_equal
|
243
|
-
assert_equal
|
242
|
+
assert_equal 2100, listing.rate('/mo')
|
243
|
+
assert_equal 25200, listing.rate('/yr')
|
244
244
|
assert_equal 2100, listing.rate('/desk/mo')
|
245
245
|
assert_raises RuntimeError do
|
246
246
|
listing.rate('/random')
|
@@ -250,7 +250,6 @@ class TestListing < ::Test::Unit::TestCase
|
|
250
250
|
def test_rate_percision
|
251
251
|
listing = MLS::Listing.new(:rate => 47, :rate_units => '/sqft/yr', :size => 5)
|
252
252
|
|
253
|
-
assert_equal 3.92, listing.rate
|
254
253
|
assert_equal 3.92, listing.rate('/sqft/mo')
|
255
254
|
assert_equal 47, listing.rate('/sqft/yr')
|
256
255
|
assert_equal 19.58, listing.rate('/mo')
|