textutils 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/textutils/helper/value_helper.rb +38 -0
- data/lib/textutils/version.rb +1 -1
- metadata +7 -7
@@ -160,6 +160,44 @@ module TextUtils
|
|
160
160
|
end
|
161
161
|
|
162
162
|
|
163
|
+
def match_abv( value ) # alcohol by volume (abv) e.g. 5.2%
|
164
|
+
if value =~ /^<?\s*(\d+(?:\.\d+)?)\s*%$/
|
165
|
+
# nb: allow leading < e.g. <0.5%
|
166
|
+
yield( $1.to_f ) # convert to decimal? how? use float?
|
167
|
+
true # bingo - match found
|
168
|
+
else
|
169
|
+
false # no match found
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def match_og( value ) # plato (stammwuerze/gravity?) e.g. 11.2°
|
174
|
+
if value =~ /^(\d+(?:\.\d+)?)°$/
|
175
|
+
# nb: no whitespace allowed between ° and number e.g. 11.2°
|
176
|
+
yield( $1.to_f ) # convert to decimal? how? use float?
|
177
|
+
true # bingo - match found
|
178
|
+
else
|
179
|
+
false # no match found
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def match_kcal( value )
|
184
|
+
if value =~ /^(\d+(?:\.\d+)?)\s*kcal(?:\/100ml)?$/ # kcal
|
185
|
+
# nb: allow 44.4 kcal/100ml or 44.4 kcal or 44.4kcal
|
186
|
+
yield( $1.to_f ) # convert to decimal? how? use float?
|
187
|
+
true # bingo - match found
|
188
|
+
else
|
189
|
+
false # no match found
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def match_hl( value ) # hector liters (hl) 1hl = 100l
|
194
|
+
if value =~ /^(?:([0-9][0-9_ ]+[0-9]|[0-9]{1,2})\s*hl)$/ # e.g. 20_000 hl or 50hl etc.
|
195
|
+
yield( $1.gsub( /[ _]/, '' ).to_i )
|
196
|
+
true # bingo - match found
|
197
|
+
else
|
198
|
+
false # no match found
|
199
|
+
end
|
200
|
+
end
|
163
201
|
|
164
202
|
|
165
203
|
def is_website?( value )
|
data/lib/textutils/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: textutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-05-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: logutils
|
16
|
-
requirement: &
|
16
|
+
requirement: &77968240 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.5'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *77968240
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rdoc
|
27
|
-
requirement: &
|
27
|
+
requirement: &77968020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.10'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *77968020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: hoe
|
38
|
-
requirement: &
|
38
|
+
requirement: &77967800 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '3.3'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *77967800
|
47
47
|
description: textutils - Text Filters, Helpers, Readers and More
|
48
48
|
email: webslideshow@googlegroups.com
|
49
49
|
executables: []
|