Class: Babelyoda::LocalizationValue
- Inherits:
-
Object
- Object
- Babelyoda::LocalizationValue
- Defined in:
- lib/babelyoda/tanker.rb,
lib/babelyoda/localization_value.rb
Instance Attribute Summary collapse
-
#language ⇒ Object
Returns the value of attribute language.
-
#status ⇒ Object
Returns the value of attribute status.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(language, text, status = :requires_translation) ⇒ LocalizationValue
constructor
A new instance of LocalizationValue.
- #merge!(other_value, options = {}) ⇒ Object
Constructor Details
#initialize(language, text, status = :requires_translation) ⇒ LocalizationValue
Returns a new instance of LocalizationValue.
7 8 9 |
# File 'lib/babelyoda/localization_value.rb', line 7 def initialize(language, text, status = :requires_translation) @language, @text, @status = language.to_sym, text, status.to_sym end |
Instance Attribute Details
#language ⇒ Object
Returns the value of attribute language.
3 4 5 |
# File 'lib/babelyoda/localization_value.rb', line 3 def language @language end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/babelyoda/localization_value.rb', line 4 def status @status end |
#text ⇒ Object
Returns the value of attribute text.
5 6 7 |
# File 'lib/babelyoda/localization_value.rb', line 5 def text @text end |
Class Method Details
.parse_xml(node) ⇒ Object
48 49 50 51 52 |
# File 'lib/babelyoda/tanker.rb', line 48 def self.parse_xml(node) if node.text.length > 0 self.new(node[:language], node.text, node[:status]) end end |
Instance Method Details
#merge!(other_value, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/babelyoda/localization_value.rb', line 11 def merge!(other_value, = {}) updated = false = { preserve: false }.merge!() unless @language.to_sym == other_value.language.to_sym raise RuntimeError.new("Can't merge values in different languages: #{@language.to_sym} and #{other_value.language.to_sym}") end if (![:preserve] || @status.to_sym == :requires_translation) unless @text == other_value.text @text = other_value.text updated = true end end return updated end |