Class: I18nAdd::CLI::TranslationEntry

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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_pathObject (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

#localeObject (readonly)

Returns the value of attribute locale.



141
142
143
# File 'lib/i18n_add/cli.rb', line 141

def locale
  @locale
end

#valueObject (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

Returns:

  • (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_hashObject



152
153
154
# File 'lib/i18n_add/cli.rb', line 152

def to_hash
  { key_path: @key_path, value: @value }
end