Class: Translation
- Inherits:
-
Object
- Object
- Translation
- Defined in:
- lib/linguara/translation.rb
Instance Attribute Summary collapse
-
#element ⇒ Object
Returns the value of attribute element.
-
#translation_hash ⇒ Object
Returns the value of attribute translation_hash.
Instance Method Summary collapse
-
#initialize(element, options = {}) ⇒ Translation
constructor
A new instance of Translation.
- #to_hash ⇒ Object
- #to_xml(options = {}, builder_options = {}) ⇒ Object
Constructor Details
#initialize(element, options = {}) ⇒ Translation
5 6 7 8 9 10 11 12 13 |
# File 'lib/linguara/translation.rb', line 5 def initialize(element, = {}) [:translation] ||= {} [:translation][:due_date] ||= Date.today + Linguara.configuration.request_valid_for.to_i.days unless Linguara.configuration.request_valid_for.blank? [:translation][:due_date] ||= Date.today + 1.month [:return_url] ||= Linguara.configuration.return_url [:source_language] ||= I18n.locale.to_s self.element = element#.fields_to_send self.translation_hash = end |
Instance Attribute Details
#element ⇒ Object
Returns the value of attribute element.
3 4 5 |
# File 'lib/linguara/translation.rb', line 3 def element @element end |
#translation_hash ⇒ Object
Returns the value of attribute translation_hash.
3 4 5 |
# File 'lib/linguara/translation.rb', line 3 def translation_hash @translation_hash end |
Instance Method Details
#to_hash ⇒ Object
15 16 17 18 19 |
# File 'lib/linguara/translation.rb', line 15 def to_hash ret = {} ret[:request] = self.translation_hash ret end |
#to_xml(options = {}, builder_options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/linguara/translation.rb', line 21 def to_xml( = {}, = {}) [:indent] ||= 2 xml = [:builder] ||= Builder::XmlMarkup.new(:indent => [:indent]) xml.instruct! unless [:skip_instruct] xml.request do self.translation_hash.merge().each_pair do |k, v| next if k.blank? or v.blank? tag_element(xml, k, v) end xml.content :type => 'html' do self.element.fields_to_send.each_pair do |k, v| xml.paragraph(:id => k) {|x| x << v} end end end end |