Class: Rabbit::PangoMarkup
- Inherits:
-
Object
- Object
- Rabbit::PangoMarkup
- Defined in:
- lib/rabbit/pango-markup.rb
Instance Method Summary collapse
-
#initialize(name, attributes, content = nil) ⇒ PangoMarkup
constructor
A new instance of PangoMarkup.
- #to_s ⇒ Object
Constructor Details
#initialize(name, attributes, content = nil) ⇒ PangoMarkup
Returns a new instance of PangoMarkup.
21 22 23 24 25 |
# File 'lib/rabbit/pango-markup.rb', line 21 def initialize(name, attributes, content=nil) @name = name @attributes = attributes @content = content end |
Instance Method Details
#to_s ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 |