lucascaton/enumerate_it

Get the enumeration name by value

annitamos opened this issue · 2 comments

Hello
I have this class
class TimePeriod < EnumerateIt::Base
associate_values(
:hours24 => [0, '24 hours'],
:hours48 => [1, '48 hours'],
:week1 => [2, 'a week'],
:month1 => [3, 'a month']
)
end

and i am trying to find a way to give to the enumerator the integer 1 and return '48 hours'
Something like name_for(1)->'48 hours'

Am i doing something wrong or i missed something in the ReadME?
Thanks

You can write something like:

TimePeriod.t(TimePeriod::HOURS24)

which will return "24 hours".

It worked. Thank you!!