module Frenchy::Enum
Attributes
name[RW]
tag[RW]
Public Class Methods
included(base)
click to toggle source
# File lib/frenchy/enum.rb, line 3 def self.included(base) base.extend(ClassMethods) base.class_eval do @enums = {} @default = nil end end
new(attrs={})
click to toggle source
# File lib/frenchy/enum.rb, line 14 def initialize(attrs={}) attrs.each do |k, v| send("#{k}=", v) if respond_to?("#{k}=") end end
Public Instance Methods
==(other)
click to toggle source
Calls superclass method
# File lib/frenchy/enum.rb, line 40 def ==(other) (other.is_a?(Symbol) && (name == other)) || (other.respond_to?(:to_i) && (other.to_i == tag)) || (other.respond_to?(:to_s) && (other.to_s == to_s || other.to_s == name.to_s)) || super end
inspect()
click to toggle source
# File lib/frenchy/enum.rb, line 20 def inspect "\#<#{self.class.name}::#{name}=#{tag}>" end
to_i()
click to toggle source
# File lib/frenchy/enum.rb, line 24 def to_i tag end
to_s()
click to toggle source
# File lib/frenchy/enum.rb, line 36 def to_s name.to_s.underscore end
to_str()
click to toggle source
# File lib/frenchy/enum.rb, line 28 def to_str to_s end
to_sym()
click to toggle source
# File lib/frenchy/enum.rb, line 32 def to_sym name end