Class: I18nJsAssets::I18nJsFile
- Inherits:
-
Object
- Object
- I18nJsAssets::I18nJsFile
- Defined in:
- lib/i18n-js-assets/i18njs_file.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(attributes) ⇒ I18nJsFile
constructor
A new instance of I18nJsFile.
- #locales ⇒ Object
- #only ⇒ Object
- #overwrite(new_attributes) ⇒ Object
- #write(path) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ I18nJsFile
Returns a new instance of I18nJsFile.
23 24 25 |
# File 'lib/i18n-js-assets/i18njs_file.rb', line 23 def initialize(attributes) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
21 22 23 |
# File 'lib/i18n-js-assets/i18njs_file.rb', line 21 def attributes @attributes end |
Class Method Details
.from_hash(hash) ⇒ Object
16 17 18 |
# File 'lib/i18n-js-assets/i18njs_file.rb', line 16 def from_hash(hash) new(hash) end |
.load(contents) ⇒ Object
8 9 10 |
# File 'lib/i18n-js-assets/i18njs_file.rb', line 8 def load(contents) from_hash(YAML.load(contents)) end |
.load_file(file) ⇒ Object
12 13 14 |
# File 'lib/i18n-js-assets/i18njs_file.rb', line 12 def load_file(file) load(File.read(file)) end |
Instance Method Details
#dump ⇒ Object
43 44 45 |
# File 'lib/i18n-js-assets/i18njs_file.rb', line 43 def dump YAML.dump(attributes) end |
#locales ⇒ Object
31 32 33 |
# File 'lib/i18n-js-assets/i18njs_file.rb', line 31 def locales attributes['locales'] end |
#only ⇒ Object
27 28 29 |
# File 'lib/i18n-js-assets/i18njs_file.rb', line 27 def only attributes['only'] end |
#overwrite(new_attributes) ⇒ Object
35 36 37 |
# File 'lib/i18n-js-assets/i18njs_file.rb', line 35 def overwrite(new_attributes) self.class.from_hash(attributes.merge(new_attributes)) end |
#write(path) ⇒ Object
39 40 41 |
# File 'lib/i18n-js-assets/i18njs_file.rb', line 39 def write(path) File.write(path, dump) end |