Class: GetPomo::Translation
- Inherits:
-
Object
- Object
- GetPomo::Translation
- Defined in:
- lib/get_pomo/translation.rb
Constant Summary collapse
- FUZZY_REGEX =
/fuzzy\n$/
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#msgid ⇒ Object
Returns the value of attribute msgid.
-
#msgstr ⇒ Object
Returns the value of attribute msgstr.
Instance Method Summary collapse
- #add_text(text, options) ⇒ Object
- #complete? ⇒ Boolean
- #fuzzy=(value) ⇒ Object
- #fuzzy? ⇒ Boolean
- #plural? ⇒ Boolean
- #to_hash ⇒ Object
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
4 5 6 |
# File 'lib/get_pomo/translation.rb', line 4 def comment @comment end |
#msgid ⇒ Object
Returns the value of attribute msgid.
4 5 6 |
# File 'lib/get_pomo/translation.rb', line 4 def msgid @msgid end |
#msgstr ⇒ Object
Returns the value of attribute msgstr.
4 5 6 |
# File 'lib/get_pomo/translation.rb', line 4 def msgstr @msgstr end |
Instance Method Details
#add_text(text, options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/get_pomo/translation.rb', line 6 def add_text(text,) to = [:to] if to.to_sym == :msgid_plural self.msgid = [msgid] unless msgid.is_a? Array msgid[1] = msgid[1].to_s + text elsif to.to_s =~ /^msgstr\[(\d)\]$/ self.msgstr ||= [] msgstr[$1.to_i] = msgstr[$1.to_i].to_s + text else #simple form send("#{to}=",send(to).to_s+text) end end |
#complete? ⇒ Boolean
24 25 26 |
# File 'lib/get_pomo/translation.rb', line 24 def complete? not msgid.nil? and not msgstr.nil? end |
#fuzzy=(value) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/get_pomo/translation.rb', line 32 def fuzzy=(value) if value and not fuzzy? add_text "\nfuzzy", :to=>:comment else self.comment = comment.to_s.split(/$/).reject{|line|line=~FUZZY_REGEX}.join("\n") end end |
#fuzzy? ⇒ Boolean
28 29 30 |
# File 'lib/get_pomo/translation.rb', line 28 def fuzzy? comment =~ FUZZY_REGEX end |
#plural? ⇒ Boolean
40 41 42 |
# File 'lib/get_pomo/translation.rb', line 40 def plural? msgid.is_a? Array or msgstr.is_a? Array end |
#to_hash ⇒ Object
20 21 22 |
# File 'lib/get_pomo/translation.rb', line 20 def to_hash {:msgid=>msgid,:msgstr=>msgstr,:comment=>comment}.reject{|k,value|value.nil?} end |