class Undies::Element::Open
Public Class Methods
new(name, *args, &build)
click to toggle source
# File lib/undies/element.rb, line 79 def initialize(name, *args, &build) @name = name.to_s @attrs = {} @content = [] @build = nil proxy(args, build) end
Public Instance Methods
==(other)
click to toggle source
# File lib/undies/element.rb, line 108 def ==(other) other.instance_variable_get("@name") == @name && other.instance_variable_get("@attrs") == @attrs && other.instance_variable_get("@content") == @content end
__build()
click to toggle source
# File lib/undies/element.rb, line 96 def __build @build.call if @build end
__content()
click to toggle source
# File lib/undies/element.rb, line 92 def __content @content.collect{ |c| Undies::Template.escape_html(c) }.join end
__end_tag()
click to toggle source
# File lib/undies/element.rb, line 100 def __end_tag "</#{@name}>" end
__start_tag()
click to toggle source
# File lib/undies/element.rb, line 88 def __start_tag "<#{@name}#{Undies::Element.hash_attrs(@attrs)}>" end
to_s()
click to toggle source
# File lib/undies/element.rb, line 104 def to_s Undies::Raw.new("#{__start_tag}#{__content}#{__end_tag}") end
to_str(*args)
click to toggle source
overriding this because the base Node class defines a 'to_s' method that needs to be honored
# File lib/undies/element.rb, line 116 def to_str(*args) "Undies::Element::Open:#{self.object_id} " + "@name=#{@name.inspect}, @attrs=#{@attrs.inspect}, @content=#{@content.inspect}" end
Also aliased as: inspect
Private Instance Methods
proxy(args, build)
click to toggle source
# File lib/undies/element.rb, line 124 def proxy(args, build) if args.last.kind_of?(Hash) @attrs.merge!(args.pop) end @content.push *args @build = build self end