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)


13
14
15
16
# File 'lib/magic_xml.rb', line 13

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



19
20
21
22
23
24
25
# File 'lib/magic_xml.rb', line 19

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



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

alias_method :eqeqeq_before_magic_xml, :===