Sha256: 1f2aa802262c5e65747d80c101f8b2009696ce5e01f0f1fc15899c18729d0ede

Contents?: true

Size: 565 Bytes

Versions: 1

Compression:

Stored size: 565 Bytes

Contents

module Renum
  class EnumeratedValue
    
    class << self
      include Enumerable
      extend Forwardable
      
      def_delegators :values, :each, :[]
      
      def values
        @values ||= []
      end
      
    end
    
    include Comparable
    attr_reader :name
    
    def initialize name
      @name = name.to_s
      self.class.values << self
    end
    
    def to_s
      "#{self.class}::#{name}"
    end
    
    def index
      self.class.values.index self
    end
    
    def <=> other
      index <=> other.index
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renum-0.0.3 lib/renum/enumerated_value.rb