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.
-
#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
- #translated_string_for_lang(lang, default_lang = nil) ⇒ Object
Constructor Details
#initialize(key) ⇒ StringsRow
Returns a new instance of StringsRow.
18 19 20 21 22 23 |
# File 'lib/twine/stringsfile.rb', line 18 def initialize(key) @key = key @comment = nil = 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 |
#tags ⇒ Object
Returns the value of attribute tags.
15 16 17 |
# File 'lib/twine/stringsfile.rb', line 15 def 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
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/twine/stringsfile.rb', line 25 def (, include_untagged) if == nil || .length == 0 # The user did not specify any tags. Everything passes. return true elsif == nil || .length == 0 # This row has no tags. return (include_untagged) ? true : false else .each do |tag| if .include? tag return true end end end return false end |
#translated_string_for_lang(lang, default_lang = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/twine/stringsfile.rb', line 43 def translated_string_for_lang(lang, default_lang=nil) if @translations[lang] return @translations[lang] elsif default_lang.respond_to?("each") default_lang.each do |def_lang| if @translations[def_lang] return @translations[def_lang] end end return nil else return @translations[default_lang] end end |