Class: Yamlt::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/yamlt/loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(filepath) ⇒ Loader

Returns a new instance of Loader.



10
11
12
13
# File 'lib/yamlt/loader.rb', line 10

def initialize(filepath)
  @filepath = filepath
  @loaded = false
end

Instance Method Details

#[](key) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/yamlt/loader.rb', line 15

def [](key)
  path = path0(key)
  value = values
  path.each do |fragment|
    value = value[fragment]
    return nil unless value
  end
  value
end

#languageObject



25
26
27
28
29
30
# File 'lib/yamlt/loader.rb', line 25

def language
  @locale ||=
    begin
      values.keys.first || @filepath[/(\w+)\.yml$/, 1]
    end
end