"DTD/xhtml1-strict.dtd">
represents a key value pair in HTML Element
# File lib/amrita/node.rb, line 31
def initialize(key, value=nil)
@key = key.intern
case value
when nil
@value = nil
when String
@value = value.frozen_copy
else
@value = value.to_s.freeze
end
end
# File lib/amrita/node.rb, line 43
def clone
Attr.new(@key, @value)
end
# File lib/amrita/node.rb, line 47
def ==(x)
return false unless x.kind_of?(Attr)
x.key_symbol == @key and x.value == @value
end
# File lib/amrita/node.rb, line 53
def key
@key.id2name
end
# File lib/amrita/node.rb, line 58
def key_symbol
@key
end
# File lib/amrita/node.rb, line 62
def to_ruby
if key =~ /^\w+$/
if value
"a(:#{key}, \"#{value}\")"
else
"a(:#{key})"
end
else
if value
"a(\"#{key}\", \"#{value}\")"
else
"a(\"#{key}\")"
end
end
end
|