No commit activity in last 3 years
No release in over 3 years
Add enumeration to your ruby classes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.6
>= 0
~> 2.13
 Project Readme

ActAsEnumerable

Build Status Coveralls Dependency Status Code Climate Gem Version

Add enumeration to your ruby classes

Installation

gem install act_as_enumerable

Or in your Gemfile:

gem 'act_as_enumerable'

Usage

class Person
  attr_accessor :gender

  def initialize opts
    @gender = opts[:gender]
  end

  enum :gender, %w(male female)
end

cameron = Person.new gender: :male

p Person.gender_values
#=> ['male', 'female']

p Person.gender_captions
#=> ['Male', 'Female']

p cameron.gender
#=> 'male'

p cameron.male?
#=> true
p cameron.female?
#=> false

p cameron.female!
#=> 'female'
p cameron.male?
#=> false
p cameron.female?
#=> true

p cameron.gender_caption
#=> 'Female'

Contributing

  1. Fork repository
  2. Create a branch following a successfull branching model
  3. Write your feature/fix
  4. Write tests
  5. Pull request

Licence

Released under the MIT License. See the LICENSE file for further details.