Class: GettextSwap::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/gettext_swap/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
# File 'lib/gettext_swap/configuration.rb', line 7

def initialize
  @rules = []
end

Instance Attribute Details

#rulesObject (readonly)

Returns the value of attribute rules.



5
6
7
# File 'lib/gettext_swap/configuration.rb', line 5

def rules
  @rules
end

Instance Method Details

#read_yaml(yaml) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gettext_swap/configuration.rb', line 11

def read_yaml(yaml)
  root = yaml['swap']

  raise(
    GettextSwap::Exception,
    "root 'swap' element must be specified") unless root
  # Be atomic, either load the whole file, or don't load it at all
  tuples = root.map { |tuple| read_tuple(tuple) }
  @rules = tuples.freeze
  true
end