frequency 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/frequency.gemspec +1 -1
- data/lib/frequency.rb +6 -2
- data/spec/frequency_spec.rb +52 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/frequency.gemspec
CHANGED
data/lib/frequency.rb
CHANGED
@@ -73,12 +73,16 @@ class Frequency
|
|
73
73
|
|
74
74
|
def per_decade
|
75
75
|
value = FREQUENCIES[plain_text]
|
76
|
-
|
76
|
+
return nil unless value
|
77
|
+
return nil unless value[0]
|
78
|
+
value[0]
|
77
79
|
end
|
78
80
|
|
79
81
|
def per_year
|
80
82
|
value = FREQUENCIES[plain_text]
|
81
|
-
|
83
|
+
return nil unless value
|
84
|
+
return nil unless value[0]
|
85
|
+
value[0] / 10.0
|
82
86
|
end
|
83
87
|
|
84
88
|
def valid?
|
data/spec/frequency_spec.rb
CHANGED
@@ -124,6 +124,58 @@ describe "Frequency" do
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
+
describe "other" do
|
128
|
+
before do
|
129
|
+
@freq = Frequency.new("other")
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should be valid" do
|
133
|
+
@freq.plain_text.should == "other"
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should be valid" do
|
137
|
+
@freq.valid?.should be_true
|
138
|
+
end
|
139
|
+
|
140
|
+
it "#per_year should be correct" do
|
141
|
+
@freq.per_year.should == nil
|
142
|
+
end
|
143
|
+
|
144
|
+
it "#per_decade should be correct" do
|
145
|
+
@freq.per_decade.should == nil
|
146
|
+
end
|
147
|
+
|
148
|
+
it "< should be undefined" do
|
149
|
+
lambda {
|
150
|
+
@freq.should < Frequency.new('monthly')
|
151
|
+
}.should raise_error(Frequency::Undefined)
|
152
|
+
end
|
153
|
+
|
154
|
+
it "<= should be undefined" do
|
155
|
+
lambda {
|
156
|
+
@freq.should <= Frequency.new('monthly')
|
157
|
+
}.should raise_error(Frequency::Undefined)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "== should be undefined" do
|
161
|
+
lambda {
|
162
|
+
@freq.should == Frequency.new('monthly')
|
163
|
+
}.should raise_error(Frequency::Undefined)
|
164
|
+
end
|
165
|
+
|
166
|
+
it ">= should be undefined" do
|
167
|
+
lambda {
|
168
|
+
@freq.should >= Frequency.new('monthly')
|
169
|
+
}.should raise_error(Frequency::Undefined)
|
170
|
+
end
|
171
|
+
|
172
|
+
it "> should be undefined" do
|
173
|
+
lambda {
|
174
|
+
@freq.should > Frequency.new('monthly')
|
175
|
+
}.should raise_error(Frequency::Undefined)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
127
179
|
# ---
|
128
180
|
|
129
181
|
describe "list" do
|