Class: Cronex::Resource
- Inherits:
-
Object
- Object
- Cronex::Resource
- Defined in:
- lib/cronex/resource.rb
Instance Attribute Summary collapse
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Instance Method Summary collapse
- #[](key) ⇒ Object (also: #get)
-
#initialize(loc = :en) ⇒ Resource
constructor
A new instance of Resource.
- #load(loc) ⇒ Object
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
#locale ⇒ Object
Returns the value of attribute locale.
6 7 8 |
# File 'lib/cronex/resource.rb', line 6 def locale @locale end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
6 7 8 |
# File 'lib/cronex/resource.rb', line 6 def @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 |