Class: I18nYamlEditor::Translation
- Inherits:
-
Object
- Object
- I18nYamlEditor::Translation
- Defined in:
- lib/i18n_yaml_editor/translation.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#name ⇒ Object
Returns the value of attribute name.
- #text ⇒ Object
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Translation
constructor
A new instance of Translation.
- #key ⇒ Object
- #locale ⇒ Object
- #number_of_lines ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Translation
Returns a new instance of Translation.
8 9 10 |
# File 'lib/i18n_yaml_editor/translation.rb', line 8 def initialize attributes={} @name, @file, @text = attributes.values_at(:name, :file, :text) end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
5 6 7 |
# File 'lib/i18n_yaml_editor/translation.rb', line 5 def file @file end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/i18n_yaml_editor/translation.rb', line 5 def name @name end |
#text ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/i18n_yaml_editor/translation.rb', line 12 def text if @text.is_a?(String) if @text.match(/\A\s*\z/) nil else @text.gsub(/\r\n/, "\n") end else @text end end |
Instance Method Details
#key ⇒ Object
24 25 26 |
# File 'lib/i18n_yaml_editor/translation.rb', line 24 def key @key ||= self.name.split(".")[1..-1].join(".") end |
#locale ⇒ Object
28 29 30 |
# File 'lib/i18n_yaml_editor/translation.rb', line 28 def locale @locale ||= self.name.split(".").first end |
#number_of_lines ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/i18n_yaml_editor/translation.rb', line 32 def number_of_lines if text text.scan(/\n/).size + 1 else 1 end end |