Class: Locraft::Localization
- Inherits:
-
Object
- Object
- Locraft::Localization
- Defined in:
- lib/locraft/localization.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#key ⇒ Object
Returns the value of attribute key.
-
#language ⇒ Object
Returns the value of attribute language.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
4 5 6 |
# File 'lib/locraft/localization.rb', line 4 def comment @comment end |
#key ⇒ Object
Returns the value of attribute key.
5 6 7 |
# File 'lib/locraft/localization.rb', line 5 def key @key end |
#language ⇒ Object
Returns the value of attribute language.
3 4 5 |
# File 'lib/locraft/localization.rb', line 3 def language @language end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/locraft/localization.rb', line 6 def value @value end |
Class Method Details
.load_with_csv_row(row, config, lang) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/locraft/localization.rb', line 8 def self.load_with_csv_row(row, config, lang) localization = Localization.new localization.language = lang localization.comment = row[config.gdoc_comments_column]&.strip localization.key = (row[config.gdoc_keys_column] || row[config.default_lang])&.strip localization.value = (row[lang] || row[config.default_lang])&.strip localization end |
Instance Method Details
#to_line ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/locraft/localization.rb', line 21 def to_line content = '' if valid? content += "/* #{comment} */" unless comment.nil? content += %(\n"#{key}" = "#{value}";\n) end content end |
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/locraft/localization.rb', line 17 def valid? !(key.nil? or value.nil?) end |