class Rabbit::PangoMarkup

Public Class Methods

new(name, attributes, content=nil) click to toggle source
# File lib/rabbit/pango-markup.rb, line 21
def initialize(name, attributes, content=nil)
  @name = name
  @attributes = attributes
  @content = content
end

Public Instance Methods

to_s() click to toggle source
# File lib/rabbit/pango-markup.rb, line 27
def to_s
  tag = "<#{@name}"
  @attributes.each do |name, value|
    next if value.nil?
    formatter_name = Utils.to_class_name(name)
    if Format.const_defined?(formatter_name)
      formatter = Format.const_get(formatter_name).new(value)
      value = formatter.pango_value
    end
    tag << " #{CGI.escapeHTML(name.to_s)}='#{CGI.escapeHTML(value.to_s)}'"
  end
  tag << ">"
  tag << @content.to_s if @content
  tag << "</#{@name}>"
  tag
end