class TaskJuggler::XMLText

This is a specialized XMLElement to represent a simple text.

Public Class Methods

new(text) click to toggle source
Calls superclass method TaskJuggler::XMLElement::new
# File lib/taskjuggler/XMLElement.rb, line 160
def initialize(text)
  super(nil, {})
  raise 'Text may not be nil' unless text
  @text = text
end

Public Instance Methods

to_s(indent) click to toggle source
# File lib/taskjuggler/XMLElement.rb, line 166
def to_s(indent)
  out = ''
  @text.each_utf8_char do |c|
    case c
    when '<'
      out << '&lt;'
    when '>'
      out << '&gt;'
    when '&'
      out << '&amp;'
    else
      out << c
    end
  end

  out
end