Class: I18nYamlEditor::Key
- Inherits:
-
Object
- Object
- I18nYamlEditor::Key
- Defined in:
- lib/i18n_yaml_editor/key.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#translations ⇒ Object
Returns the value of attribute translations.
Instance Method Summary collapse
- #add_translation(translation) ⇒ Object
- #category ⇒ Object
- #complete? ⇒ Boolean
- #empty? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Key
constructor
A new instance of Key.
Constructor Details
#initialize(attributes = {}) ⇒ Key
Returns a new instance of Key.
9 10 11 12 |
# File 'lib/i18n_yaml_editor/key.rb', line 9 def initialize attributes={} @name = attributes[:name] @translations = Set.new end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/i18n_yaml_editor/key.rb', line 7 def name @name end |
#translations ⇒ Object
Returns the value of attribute translations.
7 8 9 |
# File 'lib/i18n_yaml_editor/key.rb', line 7 def translations @translations end |
Instance Method Details
#add_translation(translation) ⇒ Object
14 15 16 |
# File 'lib/i18n_yaml_editor/key.rb', line 14 def add_translation translation self.translations.add(translation) end |
#category ⇒ Object
18 19 20 |
# File 'lib/i18n_yaml_editor/key.rb', line 18 def category @category ||= self.name.split(".").first end |
#complete? ⇒ Boolean
22 23 24 |
# File 'lib/i18n_yaml_editor/key.rb', line 22 def complete? self.translations.all? {|t| t.text.to_s !~ /\A\s*\z/} || empty? end |
#empty? ⇒ Boolean
26 27 28 |
# File 'lib/i18n_yaml_editor/key.rb', line 26 def empty? self.translations.all? {|t| t.text.to_s =~ /\A\s*\z/} end |