Class: Jcsv::RBParseBigDecimal
Overview
Instance Attribute Summary collapse
-
#dfs ⇒ Object
readonly
Returns the value of attribute dfs.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
Attributes included from NextFilter
Instance Method Summary collapse
- #execute(value, context) ⇒ Object
-
#initialize(locale) ⇒ RBParseBigDecimal
constructor
A new instance of RBParseBigDecimal.
Methods included from NextFilter
Constructor Details
#initialize(locale) ⇒ RBParseBigDecimal
Returns a new instance of RBParseBigDecimal.
156 157 158 159 160 161 162 |
# File 'lib/numeric_filters.rb', line 156 def initialize(locale) @locale = locale @dfs = DFSymbols.new(locale) @grouping_separator = @dfs.grouping_separator @decimal_separator = @dfs.decimal_separator super() end |
Instance Attribute Details
#dfs ⇒ Object (readonly)
Returns the value of attribute dfs.
154 155 156 |
# File 'lib/numeric_filters.rb', line 154 def dfs @dfs end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
153 154 155 |
# File 'lib/numeric_filters.rb', line 153 def locale @locale end |
Instance Method Details
#execute(value, context) ⇒ Object
164 165 166 167 168 169 170 |
# File 'lib/numeric_filters.rb', line 164 def execute(value, context) validateInputNotNull(value, context) # raise "BigDecimal expects a String as input not #{value}" if !(value.is_a? String) bd = BigDecimal.new(value.gsub(@grouping_separator.chr, ""). gsub(@decimal_separator.chr, ".")) exec_next(bd, context) end |