lib/osheet/format/numeric.rb in osheet-1.0.0.rc.2 vs lib/osheet/format/numeric.rb in osheet-1.0.0.rc.3
- old
+ new
@@ -6,12 +6,21 @@
class Numeric
include Enumeration
attr_accessor :decimal_places, :comma_separator
- enum :symbol, [:none, :dollar, :euro]
- enum :negative_numbers, [:black, :black_parenth, :red, :red_parenth]
+ enum :symbol, {
+ :none => "none",
+ :dollar => "dollar",
+ :euro => "euro"
+ }
+ enum :negative_numbers, {
+ :black => "black",
+ :black_parenth => "black_parenth",
+ :red => "red",
+ :red_parenth => "red_parenth"
+ }
def initialize(opts={})
self.symbol = opts[:symbol] || :none
self.decimal_places = opts[:decimal_places] || 0
self.comma_separator = opts.has_key?(:comma_separator) ? opts[:comma_separator] : false
@@ -64,17 +73,17 @@
end
def negative_numbers_style
case @negative_numbers
- when :black
+ when 'black'
numeric_style
- when :red
+ when 'red'
"#{numeric_style};[Red]#{numeric_style}"
- when :black_parenth
+ when 'black_parenth'
"#{numeric_style}_);\(#{numeric_style}\)"
- when :red_parenth
+ when 'red_parenth'
"#{numeric_style}_);[Red]\(#{numeric_style}\)"
end
end
def negative_numbers_key
@negative_numbers.to_s.gsub('_', '')
@@ -97,12 +106,12 @@
end
def symbol_style
case @symbol
- when :dollar
+ when 'dollar'
"\"$\"#{symbol_suffix}"
- when :euro
+ when 'euro'
"\"€\"#{symbol_suffix}"
else
''
end
end