module Kernel
# simple (sequential) enumerated values
def enum(*syms)
syms.each { s const_set(s, s.to_s) }
const_set(:DEFAULT, syms.first) unless syms.nil?
end
end
//and the usage
require 'kernel'
module Constants
module Gradient
enum :DOWNSLOPE, :LEVEL, :UPSLOPE
end
module TreeCover
enum :GOOD, :BAD, :OK
end
module TrafficDensity
enum :LOW, :MEDIUM, :HIGH
end
end
0 Comments:
Post a Comment