blob: 369892a28a593f52192fb4323599a17a3cf45ac3 [file] [log] [blame]
# package etch/bindings/ruby/support
class Enum
include Comparable
def initialize( name, ord )
@name = name
@ord = ord
end
def <=>( other )
return @ord<=>( other.ord )
end
def to_s
return @name.to_s
end
attr :name
attr :ord
alias :to_int :ord
alias :to_i :ord
protected :initialize
end
# Usage:
#class PrimaryColor < Enum
# RED = PrimaryColor.new( :RED, 0 )
# GREEN = PrimaryColor.new( :GREEN, 1 )
# BLUE = PrimaryColor.new( :BLUE, 2 )
#end