Class: Amrita::Attr

Class Amrita::Attr |
In: | lib/amrita/node.rb
Parent: | Object

represents a `key` `value` pair in HTML Element

Methods

== clone key key_symbol new to_ruby

Attributes

:value | [RW] |

Public Class methods

new(key, value=nil)

    # 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

Public Instance methods

clone()

    # File lib/amrita/node.rb, line 43
        def clone
          Attr.new(@key, @value)
        end

==(x)

    # 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

key()

return `key` as String

    # File lib/amrita/node.rb, line 53
        def key
          @key.id2name
        end

key_symbol()

return `key` as Symbol

    # File lib/amrita/node.rb, line 58
        def key_symbol
          @key
        end

to_ruby()

    # 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