class Zenithal::Tag
Attributes
content[RW]
name[RW]
Public Class Methods
build(name = nil, clazz = nil, close = true, &block)
click to toggle source
# File source/zenml/utility.rb, line 61 def self.build(name = nil, clazz = nil, close = true, &block) tag = Tag.new(name, clazz, close) block.call(tag) return tag end
new(name = nil, clazz = nil, close = true)
click to toggle source
# File source/zenml/utility.rb, line 9 def initialize(name = nil, clazz = nil, close = true) @name = name @attributes = (clazz) ? {"class" => clazz} : {} @content = "" @close = close end
Public Instance Methods
<<(content)
click to toggle source
# File source/zenml/utility.rb, line 32 def <<(content) @content << content end
[](key)
click to toggle source
# File source/zenml/utility.rb, line 16 def [](key) return @attributes[key] end
[]=(key, value)
click to toggle source
# File source/zenml/utility.rb, line 20 def []=(key, value) @attributes[key] = value end
class()
click to toggle source
# File source/zenml/utility.rb, line 24 def class return @attributes["class"] end
class=(clazz)
click to toggle source
# File source/zenml/utility.rb, line 28 def class=(clazz) @attributes["class"] = clazz end
to_s()
click to toggle source
# File source/zenml/utility.rb, line 36 def to_s result = "" if @name result << "<" result << @name @attributes.each do |key, value| result << " #{key}=\"#{value}\"" end result << ">" result << @content if @close result << "</" result << @name result << ">" end else result << @content end return result end
to_str()
click to toggle source
# File source/zenml/utility.rb, line 57 def to_str return self.to_s end