Class: I18nYamlEditor::Key
- Inherits:
-
Object
- Object
- I18nYamlEditor::Key
- Defined in:
- lib/i18n_yaml_editor/key.rb
Overview
This is a key
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
Adds a translation to this key’s list of translations.
-
#category ⇒ Object
This key’s category.
- #complete? ⇒ Boolean
- #empty? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Key
constructor
A new instance of Key.
Constructor Details
#initialize(attributes = {}) ⇒ Key
Returns a new instance of Key.
10 11 12 13 |
# File 'lib/i18n_yaml_editor/key.rb', line 10 def initialize(attributes = {}) @name = attributes[:name] @translations = Set.new end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/i18n_yaml_editor/key.rb', line 8 def name @name end |
#translations ⇒ Object
Returns the value of attribute translations.
8 9 10 |
# File 'lib/i18n_yaml_editor/key.rb', line 8 def translations @translations end |
Instance Method Details
#add_translation(translation) ⇒ Object
Adds a translation to this key’s list of translations
16 17 18 |
# File 'lib/i18n_yaml_editor/key.rb', line 16 def add_translation(translation) translations.add(translation) end |
#category ⇒ Object
This key’s category
21 22 23 |
# File 'lib/i18n_yaml_editor/key.rb', line 21 def category @category ||= name.split('.').first end |
#complete? ⇒ Boolean
25 26 27 |
# File 'lib/i18n_yaml_editor/key.rb', line 25 def complete? translations.all? { |t| t.text.to_s !~ /\A\s*\z/ } || empty? end |
#empty? ⇒ Boolean
29 30 31 |
# File 'lib/i18n_yaml_editor/key.rb', line 29 def empty? translations.all? { |t| t.text.to_s =~ /\A\s*\z/ } end |