Class: Bisu::Config
- Inherits:
-
Object
- Object
- Bisu::Config
- Defined in:
- lib/bisu/config.rb
Instance Method Summary collapse
- #dictionary ⇒ Object
-
#initialize(hash:) ⇒ Config
constructor
A new instance of Config.
- #localize_files ⇒ Object
- #to_h ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(hash:) ⇒ Config
Returns a new instance of Config.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/bisu/config.rb', line 3 def initialize(hash:) @hash = hash.deep_symbolize @hash.validate_structure!(CONFIG_STRUCT) unless dict_struct = DICTIONARY_STRUCT[@hash[:dictionary][:type]] raise ArgumentError.new("unknown dictionary type '#{@hash[:dictionary][:type]}'") end @hash[:dictionary].validate_structure!(dict_struct) end |
Instance Method Details
#dictionary ⇒ Object
18 19 20 |
# File 'lib/bisu/config.rb', line 18 def dictionary @hash[:dictionary] end |
#localize_files ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/bisu/config.rb', line 26 def localize_files @hash[:translate].each do |t| @hash[:languages].each do |l| downcase_locale = l[:locale].downcase.gsub("-", "_").gsub(" ", "_") yield(t[:in], (t[:"out_#{downcase_locale}"] || t[:out]) % l, l[:language], l[:locale]) end end end |
#to_h ⇒ Object
14 15 16 |
# File 'lib/bisu/config.rb', line 14 def to_h @hash end |
#type ⇒ Object
22 23 24 |
# File 'lib/bisu/config.rb', line 22 def type @hash[:type] end |