active_stripper 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_stripper.rb +2 -0
- data/lib/active_stripper/helpers.rb +33 -0
- data/lib/active_stripper/version.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a277eb0491e8dcc6b84db07c1268a910167b82f2
|
4
|
+
data.tar.gz: f7a1f7e001594d9d02551a6630b51dc7dfcebb09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efb4007419b663ecb2a2540ebdbc6c6d03f53789c24b7692c36360de5796fd6057ffcc6cf21c38e9935326501b5ea675e7f6c82433abca33d58cadf9bab5bda3
|
7
|
+
data.tar.gz: ef8d95f1eb7d029364297ff1d37455f5e9eab8f69f35c6493151e0d1af46c3b2bf106a2cd1c0d213779b22add9cf0c78fadb4a16fb492fd1d5a560234763c639
|
data/lib/active_stripper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
#coding: utf-8
|
2
|
+
|
1
3
|
# Any helper processor in this module need to have their first argument set to contain
|
2
4
|
# to value to be processed
|
3
5
|
module ActiveStripper
|
@@ -75,6 +77,37 @@ module ActiveStripper
|
|
75
77
|
return if !val || val == ""
|
76
78
|
return val
|
77
79
|
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# Convert value to Integer value if format match.
|
83
|
+
# nil and empty string returns 0 other value are converted with
|
84
|
+
# Integer(val) command if value is not convertible raise an argument Error
|
85
|
+
# Only to use if val is NOT a BigDecimal or should results in one
|
86
|
+
#
|
87
|
+
# @param [Any] val Value to cast into integer
|
88
|
+
#
|
89
|
+
# @return [Integer] Casted value
|
90
|
+
#
|
91
|
+
def cast_to_int(val)
|
92
|
+
return 0 if !val || val == ""
|
93
|
+
return Integer(val)
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Convert value to Float value if format match.
|
98
|
+
# nil and empty string returns 0.0 other value are converted with
|
99
|
+
# Float(val) command if value is not convertible raise an argument Error
|
100
|
+
# Only to use if val is NOT a BigDecimal or should results in one
|
101
|
+
#
|
102
|
+
# @param [Any] val Value to cast into float
|
103
|
+
#
|
104
|
+
# @return [Float] Casted value
|
105
|
+
#
|
106
|
+
def cast_to_float(val)
|
107
|
+
return 0.0 if !val || val == ""
|
108
|
+
return Float( (val.is_a?(String)) ? val.gsub(",", ".") : val )
|
109
|
+
end
|
110
|
+
|
78
111
|
end
|
79
112
|
end
|
80
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_stripper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- François TCHENG
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|