Class: I18nAdd::CLI::TranslationEntry
- Inherits:
-
Object
- Object
- I18nAdd::CLI::TranslationEntry
- Defined in:
- lib/i18n_add/cli.rb
Overview
Represents a single translation entry with validation
Constant Summary collapse
- TRANSLATION_FORMAT =
/^([a-z]{2})\.(.+?)=(.*)$/m
Instance Attribute Summary collapse
-
#key_path ⇒ Object
readonly
Returns the value of attribute key_path.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(translation_string) ⇒ TranslationEntry
constructor
A new instance of TranslationEntry.
- #to_hash ⇒ Object
Constructor Details
#initialize(translation_string) ⇒ TranslationEntry
Returns a new instance of TranslationEntry.
143 144 145 146 |
# File 'lib/i18n_add/cli.rb', line 143 def initialize(translation_string) @raw_string = translation_string parse_translation end |
Instance Attribute Details
#key_path ⇒ Object (readonly)
Returns the value of attribute key_path.
141 142 143 |
# File 'lib/i18n_add/cli.rb', line 141 def key_path @key_path end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
141 142 143 |
# File 'lib/i18n_add/cli.rb', line 141 def locale @locale end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
141 142 143 |
# File 'lib/i18n_add/cli.rb', line 141 def value @value end |
Class Method Details
.valid_format?(translation_string) ⇒ Boolean
148 149 150 |
# File 'lib/i18n_add/cli.rb', line 148 def self.valid_format?(translation_string) translation_string =~ TRANSLATION_FORMAT end |
Instance Method Details
#to_hash ⇒ Object
152 153 154 |
# File 'lib/i18n_add/cli.rb', line 152 def to_hash { key_path: @key_path, value: @value } end |