Module: JottitTo::ArrayExtender

Defined in:
lib/jottit-to.rb

Instance Method Summary collapse

Instance Method Details

#to_textObject

e.g. self => “foonbarn”



71
72
73
# File 'lib/jottit-to.rb', line 71

def to_text
  self.join("\n")
end

#to_xmlObject

e.g. self => “<?xml version=”1.0“ encoding=”UTF-8“?> <items>

<item>foo</item>
<item>bar</item>

</items>“



80
81
82
83
84
85
# File 'lib/jottit-to.rb', line 80

def to_xml
  builder = Builder::XmlMarkup.new(:indent=>2)
  builder.instruct! :xml, version: '1.0', encoding: 'UTF-8'
  xml = builder.items{ self.each{|x| builder.item(x) } }
  xml
end