S
Sasa
Hello everybody...
I have a beginne's question:
I've created class for my numeric constants, it looks like:
class MyClass
NAME1 = 0
NAME2 = 1
NAME3 = 2
#etc...
def self.to_s(something)
case something
when 0
"NAME1"
when 1
"NAME2"
when 2
"NAME3"
#etc...
end
end
end
What is more elegant way to do this? Basically, I want to convert the
numerical value to string representation (ideally via identifier name).
Thanks in advance,
Sasa
I have a beginne's question:
I've created class for my numeric constants, it looks like:
class MyClass
NAME1 = 0
NAME2 = 1
NAME3 = 2
#etc...
def self.to_s(something)
case something
when 0
"NAME1"
when 1
"NAME2"
when 2
"NAME3"
#etc...
end
end
end
What is more elegant way to do this? Basically, I want to convert the
numerical value to string representation (ideally via identifier name).
Thanks in advance,
Sasa