latinum 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/latinum/resource.rb +9 -6
- data/lib/latinum/version.rb +1 -1
- data/spec/latinum/comparison_spec.rb +42 -0
- data/spec/latinum/resource_spec.rb +0 -9
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7ea6c1821dd5955481bf78aeddadb8df92d6f4e
|
4
|
+
data.tar.gz: 27b5bf126b861190724bf689e6d04ee534b789b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb53fc6b6c7067acb3129351b160a7b105e0eea8fa9395326106470bb23a66dbbd051f217bbca59820cf8cfb89f65fbf3e28d42c1e166f98a969600fe47ab7c4
|
7
|
+
data.tar.gz: b2d02183d4da42c3cf2477e96964439e99fa8ec0fcc00e27775f08c9761e68ad06986963fd90ce6cc1a59951f145d1534b07d387468e3d7073e8e3ebbe1489ad
|
data/lib/latinum/resource.rb
CHANGED
@@ -89,13 +89,16 @@ module Latinum
|
|
89
89
|
"#<#{self.class.name} #{self.to_s.dump}>"
|
90
90
|
end
|
91
91
|
|
92
|
+
# Compare with another resource or a Numeric value.
|
92
93
|
def <=> other
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
94
|
+
if other.is_a? self.class
|
95
|
+
result = @amount <=> other.amount
|
96
|
+
return result unless result == 0
|
97
|
+
|
98
|
+
result = @name <=> other.name
|
99
|
+
return result
|
100
|
+
elsif other.is_a? Numeric
|
101
|
+
@amount <=> other
|
99
102
|
end
|
100
103
|
end
|
101
104
|
|
data/lib/latinum/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'latinum/resource'
|
22
|
+
|
23
|
+
module Latinum::ComparisonSpec
|
24
|
+
describe Latinum::Resource do
|
25
|
+
it "should be comparable to numeric values" do
|
26
|
+
resource = Latinum::Resource.load("10 NZD")
|
27
|
+
|
28
|
+
expect(resource).to be < 20
|
29
|
+
expect(resource).to be > 5
|
30
|
+
expect(resource).to be == 10
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should compare with nil" do
|
34
|
+
a = Latinum::Resource.load("10 NZD")
|
35
|
+
|
36
|
+
expect{a <=> nil}.to_not raise_exception
|
37
|
+
expect{a == nil}.to_not raise_exception
|
38
|
+
expect(a <=> nil).to be == nil
|
39
|
+
expect(a == nil).to be == false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -72,14 +72,5 @@ module Latinum::ResourceSpec
|
|
72
72
|
|
73
73
|
expect(original_price / 2.0).to be == Latinum::Resource.load("5 NZD")
|
74
74
|
end
|
75
|
-
|
76
|
-
it "should compare with nil" do
|
77
|
-
a = Latinum::Resource.load("10 NZD")
|
78
|
-
|
79
|
-
expect{a <=> nil}.to_not raise_exception
|
80
|
-
expect{a == nil}.to_not raise_exception
|
81
|
-
expect(a <=> nil).to be == nil
|
82
|
-
expect(a == nil).to be == false
|
83
|
-
end
|
84
75
|
end
|
85
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: latinum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/latinum/version.rb
|
74
74
|
- spec/latinum/bank_spec.rb
|
75
75
|
- spec/latinum/collection_spec.rb
|
76
|
+
- spec/latinum/comparison_spec.rb
|
76
77
|
- spec/latinum/formatters_spec.rb
|
77
78
|
- spec/latinum/integrals_spec.rb
|
78
79
|
- spec/latinum/resource_spec.rb
|
@@ -104,6 +105,7 @@ summary: Latinum is a simple gem for managing resource computations, including m
|
|
104
105
|
test_files:
|
105
106
|
- spec/latinum/bank_spec.rb
|
106
107
|
- spec/latinum/collection_spec.rb
|
108
|
+
- spec/latinum/comparison_spec.rb
|
107
109
|
- spec/latinum/formatters_spec.rb
|
108
110
|
- spec/latinum/integrals_spec.rb
|
109
111
|
- spec/latinum/resource_spec.rb
|