wowecon 0.2.4 → 0.2.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.
- data/lib/wowecon.rb +1 -1
- data/lib/wowecon/currency_helpers.rb +3 -8
- data/spec/currency_spec.rb +5 -0
- data/spec/wowecon_spec.rb +2 -2
- metadata +2 -2
data/lib/wowecon.rb
CHANGED
@@ -21,22 +21,17 @@ module Wowecon
|
|
21
21
|
def to_s
|
22
22
|
output = ""
|
23
23
|
self.to_hash.each do |denom, value|
|
24
|
-
if value > 0 || output.length > 0
|
24
|
+
if value > 0 || output.length > 0 || denom == :copper
|
25
25
|
output += "#{value.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")}#{denom.to_s[0,1]} "
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
29
|
-
if output == ""
|
30
|
-
""
|
31
|
-
else
|
32
|
-
output.strip
|
33
|
-
end
|
28
|
+
output.strip
|
34
29
|
end
|
35
30
|
|
36
31
|
def to_html
|
37
32
|
tags = ""
|
38
33
|
self.to_hash.each do |denom, value|
|
39
|
-
if value > 0 || tags.length > 0
|
34
|
+
if value > 0 || tags.length > 0 || denom == :copper
|
40
35
|
tags += "<var class=\"#{denom.to_s}\">#{value.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")}</var>"
|
41
36
|
end
|
42
37
|
end
|
data/spec/currency_spec.rb
CHANGED
@@ -27,6 +27,11 @@ describe Wowecon::Currency do
|
|
27
27
|
@nilcurrency.should be_nil
|
28
28
|
end
|
29
29
|
|
30
|
+
it "returns a currency with a value of zero if initialised with 0" do
|
31
|
+
zero = Wowecon::Currency.new(0)
|
32
|
+
zero.class.should == Wowecon::Currency and zero.to_s.should == "0c"
|
33
|
+
end
|
34
|
+
|
30
35
|
describe "for a given valid currency" do
|
31
36
|
before do
|
32
37
|
@currency = Wowecon::Currency.new({:gold => 1420, :silver => 9, :copper => 10})
|
data/spec/wowecon_spec.rb
CHANGED
@@ -24,9 +24,9 @@ describe Wowecon do
|
|
24
24
|
|
25
25
|
# use http://data.wowecon.com/?type=price&item_name=Rock%20Furrow%20Boots to confirm
|
26
26
|
describe "With known market data" do
|
27
|
-
it "should return a value of
|
27
|
+
it "should return a value of 25000000 for this item" do
|
28
28
|
price = Wowecon.price("Rock Furrow Boots")
|
29
|
-
price.should == {:value =>
|
29
|
+
price.should == {:value => 25000000}
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: wowecon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ben Darlow
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-27 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|