Class: Symbol

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/magic_xml.rb

Overview

In Ruby 2 Symbol will be a subclass of String, and this won’t be needed any more. Before then…

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Object

Raises:

  • (ArgumentError)


35
36
37
38
# File 'lib/magic_xml.rb', line 35

def <=>(other)
    raise ArgumentError.new("comparison of #{self.class} with #{other.class} failed") unless other.is_a? Symbol
    to_s <=> other.to_s
end

#===(*args, &blk) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/magic_xml.rb', line 41

def ===(*args, &blk)
    if args.size >= 1 and args[0].is_a? XML
        self == args[0].name
    else
        eqeqeq_before_magic_xml(*args, &blk)
    end
end

#eqeqeq_before_magic_xmlObject



40
# File 'lib/magic_xml.rb', line 40

alias_method :eqeqeq_before_magic_xml, :===