Class: Twine::StringsRow
- Inherits:
-
Object
- Object
- Twine::StringsRow
- Defined in:
- lib/twine/stringsfile.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#reference_key ⇒ Object
Returns the value of attribute reference_key.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#translations ⇒ Object
readonly
Returns the value of attribute translations.
Instance Method Summary collapse
-
#initialize(key) ⇒ StringsRow
constructor
A new instance of StringsRow.
- #matches_tags?(tags, include_untagged) ⇒ Boolean
- #raw_comment ⇒ Object
- #translated_string_for_lang(lang) ⇒ Object
Constructor Details
#initialize(key) ⇒ StringsRow
Returns a new instance of StringsRow.
20 21 22 23 24 25 |
# File 'lib/twine/stringsfile.rb', line 20 def initialize(key) @key = key @comment = nil @tags = nil @translations = {} end |
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
14 15 16 |
# File 'lib/twine/stringsfile.rb', line 14 def comment @comment end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
13 14 15 |
# File 'lib/twine/stringsfile.rb', line 13 def key @key end |
#reference ⇒ Object
Returns the value of attribute reference.
17 18 19 |
# File 'lib/twine/stringsfile.rb', line 17 def reference @reference end |
#reference_key ⇒ Object
Returns the value of attribute reference_key.
18 19 20 |
# File 'lib/twine/stringsfile.rb', line 18 def reference_key @reference_key end |
#tags ⇒ Object
Returns the value of attribute tags.
15 16 17 |
# File 'lib/twine/stringsfile.rb', line 15 def @tags end |
#translations ⇒ Object (readonly)
Returns the value of attribute translations.
16 17 18 |
# File 'lib/twine/stringsfile.rb', line 16 def translations @translations end |
Instance Method Details
#matches_tags?(tags, include_untagged) ⇒ Boolean
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/twine/stringsfile.rb', line 35 def (, include_untagged) if == nil || .empty? # The user did not specify any tags. Everything passes. return true elsif @tags == nil # This row has no tags. return reference ? reference.(, include_untagged) : include_untagged elsif @tags.empty? return include_untagged else return !( & @tags).empty? end return false end |
#raw_comment ⇒ Object
31 32 33 |
# File 'lib/twine/stringsfile.rb', line 31 def raw_comment @comment end |
#translated_string_for_lang(lang) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/twine/stringsfile.rb', line 51 def translated_string_for_lang(lang) translation = [lang].flatten.map { |l| @translations[l] }.first translation = reference.translated_string_for_lang(lang) if translation.nil? && reference return translation end |