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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a002ba180aa3144b7177458f3a061e9dfa118170
4
- data.tar.gz: 40d3ed0bcd9c125b07d3c11f7835db92598932fb
3
+ metadata.gz: a277eb0491e8dcc6b84db07c1268a910167b82f2
4
+ data.tar.gz: f7a1f7e001594d9d02551a6630b51dc7dfcebb09
5
5
  SHA512:
6
- metadata.gz: 5f8c57f9ac4c478eb9592679fb226c7f41cc7e01959a9572fbebcb91dbe0196cbb349cb53be917f1808f96e7ad2ca13458ec5dcaf8b4c82a2e079d94a5f6ae2f
7
- data.tar.gz: 034942b8eb6d0e0307d9da20180f0a526bc9e8ccb84fc22bee2968be9ecffb826f06aa6e4700618b7df3bb738eddd5e30250ee7020162a70664098665e92148b
6
+ metadata.gz: efb4007419b663ecb2a2540ebdbc6c6d03f53789c24b7692c36360de5796fd6057ffcc6cf21c38e9935326501b5ea675e7f6c82433abca33d58cadf9bab5bda3
7
+ data.tar.gz: ef8d95f1eb7d029364297ff1d37455f5e9eab8f69f35c6493151e0d1af46c3b2bf106a2cd1c0d213779b22add9cf0c78fadb4a16fb492fd1d5a560234763c639
@@ -1,3 +1,5 @@
1
+ #coding: utf-8
2
+
1
3
  require "active_stripper/version"
2
4
  require "active_stripper/helpers"
3
5
 
@@ -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
@@ -1,3 +1,5 @@
1
+ #coding: utf-8
2
+
1
3
  module ActiveStripper
2
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
3
5
  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.2.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-23 00:00:00.000000000 Z
11
+ date: 2017-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler