kosher 0.1.10 → 0.1.11

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.
@@ -1,22 +1,25 @@
1
1
  module Kosher
2
- class Condition < Struct.new(:in_words)
3
- def to_i
4
- case in_words
5
- when 'new' then 1
6
- when 'mint' then 2
7
- when 'verygood' then 3
8
- when 'good' then 4
9
- when 'acceptable' then 5
10
- else 6
11
- end
2
+ class Condition < Struct.new(:grade)
3
+
4
+ alias_method :to_i, :grade
5
+
6
+ CONDITIONS = {
7
+ 'new' => 1,
8
+ 'mint' => 2,
9
+ 'verygood' => 3,
10
+ 'good' => 4,
11
+ 'acceptable' => 5 }
12
+
13
+ def initialize(string = '')
14
+ self.grade = CONDITIONS[string] || 6
12
15
  end
13
16
 
14
17
  def kosher?
15
- to_i <= 4
18
+ grade <= 4
16
19
  end
17
20
 
18
21
  def new?
19
- in_words == 'new'
22
+ grade == 1
20
23
  end
21
24
 
22
25
  def used?
@@ -1,3 +1,3 @@
1
1
  module Kosher
2
- VERSION = '0.1.10'
2
+ VERSION = '0.1.11'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  Fabricator(:kosher_condition, :class_name => 'kosher/condition') do
2
- in_words "new"
2
+ grade 1
3
3
  end
4
4
 
5
5
  Fabricator(:unkosher_condition, :class_name => 'kosher/condition') do
6
- in_words "acceptable"
6
+ grade 5
7
7
  end
@@ -49,7 +49,7 @@ module Kosher
49
49
  describe "#kosher?" do
50
50
  context "when condition is kosher" do
51
51
  before do
52
- offer.condition = Fabricate(:kosher_condition, :in_words => 'new')
52
+ offer.condition = Fabricate(:kosher_condition, :grade => 1)
53
53
  end
54
54
 
55
55
  context "when seller is kosher" do
@@ -99,7 +99,7 @@ module Kosher
99
99
 
100
100
  context "when condition is not kosher" do
101
101
  before do
102
- offer.condition = Fabricate(:kosher_condition, :in_words => "acceptable")
102
+ offer.condition = Fabricate(:kosher_condition, :grade => 5)
103
103
  end
104
104
 
105
105
  it "returns false" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: kosher
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.10
5
+ version: 0.1.11
6
6
  platform: ruby
7
7
  authors:
8
8
  - Paper Cavalier