class TaskJuggler::XMLComment

This is a specialized XMLElement to represent a comment.

Public Class Methods

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

Public Instance Methods

to_s(indent) click to toggle source
# File lib/taskjuggler/XMLElement.rb, line 206
def to_s(indent)
  '<!-- ' + canonicalize_comment(@text) + " -->\n#{' ' * indent}"
end

Private Instance Methods

canonicalize_comment(text) click to toggle source

It is crucial to canonicalize xml comment text because xml comment syntax forbids having a – in the comment body. I picked emacs’s “M-x comment-region” approach of putting a backslash between the two.

# File lib/taskjuggler/XMLElement.rb, line 216
def canonicalize_comment(text)
  new_text = text.gsub("--", "-\\-")
  new_text
end