Class: Cronex::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/cronex/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(loc = :en) ⇒ Resource

Returns a new instance of Resource.



8
9
10
# File 'lib/cronex/resource.rb', line 8

def initialize(loc = :en)
  self.locale = loc || :en
end

Instance Attribute Details

#localeObject

Returns the value of attribute locale.



6
7
8
# File 'lib/cronex/resource.rb', line 6

def locale
  @locale
end

#messagesObject (readonly)

Returns the value of attribute messages.



6
7
8
# File 'lib/cronex/resource.rb', line 6

def messages
  @messages
end

Instance Method Details

#[](key) ⇒ Object Also known as: get



28
29
30
# File 'lib/cronex/resource.rb', line 28

def [](key)
  @messages[key]
end

#load(loc) ⇒ Object



22
23
24
25
26
# File 'lib/cronex/resource.rb', line 22

def load(loc)
  file = File.join(RESOURCES_DIR,  "resources_#{loc}.yml")
  fail ResourceError, "Resource file #{file} for '#{loc}' locale not found" unless File.exist?(file)
  YAML.load_file(file)
end