class ChineseCapital::Configuration

Constants

MONEY
NORMAL

Attributes

money[RW]
normal[RW]

Public Class Methods

new() click to toggle source
# File lib/chinese_capital/configuration.rb, line 23
def initialize
  @normal = deal_attribute('normal')
  @money = deal_attribute('money')
end

Public Instance Methods

money=(hash_money) click to toggle source
# File lib/chinese_capital/configuration.rb, line 32
def money=(hash_money)
  @money = deal_attribute('money', hash_money)
end
normal=(hash_normal) click to toggle source
# File lib/chinese_capital/configuration.rb, line 28
def normal=(hash_normal)
  @normal = deal_attribute('normal', hash_normal)
end

Private Instance Methods

deal_attribute(type, value={}) click to toggle source
# File lib/chinese_capital/configuration.rb, line 38
def deal_attribute(type, value={})
  value = value.map { |k, v| [k.to_sym, v] }.to_h
  attribute = if type == 'normal'
                @normal = NORMAL.merge(value)
              elsif type == 'money'
                @money = MONEY.merge(value)
              end
  attribute[:figure] = attribute[:figure].strip.chars
  attribute[:minor_units] = attribute[:minor_units].strip.chars.unshift(nil)
  attribute[:major_units] = attribute[:major_units].strip.chars.unshift(nil)
  attribute[:decimal_units] = attribute[:decimal_units].strip.chars if attribute[:decimal_units]
  attribute
end