elskwid / enuma Goto Github PK
View Code? Open in Web Editor NEWRuby enum thing.
License: MIT License
Ruby enum thing.
License: MIT License
Bring in ideas from other libraries.
yinum
(enum)https://github.com/toplex/enum
attr_enum
syntax for adding to a classtoo many examples: see README
nice_enum
https://github.com/raphaelr/nice_enum
example:
class Number < Enum
enum :Zero, 0, :squared => 0
enum :One, 1, :note => "Average number of eyes per eyehole", :squared => 1
enum :Five, 5, :note => "Number of digits per hand", :squared => 25
end
A gist of a recent enum-like thing being used in a project. https://gist.github.com/elskwid/7113427
sholden/enum
https://github.com/sholden/enum
#valid?
to test for key existence#only
method to return only values asked for#except
method to return all but the values stipulatedexamples:
BitflagEnum.new(:global, :group, :user)
Enum.new(:jake, :finn, :princess_bubblegum, :peppermint_butler)
Partially extracted from a project in this gist: https://gist.github.com/elskwid/5811336
binarylogic/enumlogic
https://github.com/binarylogic/enumlogic
enum
)_options
method that returns hash for rails forms.valid?
method to validate inclusion of the enum field in an AR modelexamples:
Computer.enum :kind, ["apple", "dell", "hp"], :namespace => true
Computer.enum :kind, ["apple", "dell", "hp"]
Computer.enum :kind, {"apple" => "Apple", "dell" => "Dell", "hp" => "HP"}
tick-tock
light_enum
https://github.com/ddl1st/light_enum
foo.status_0?
foo.status_name
This one doesn't have much that I've considered before, putting it here for completeness.
example:
class Bar
include ActiveModel::Validations
include LightEnum
attr_accessor :status,:published
light_enum :status, ["Open","Close","Reopen",["Done","D"]],:validate => true
light_enum :published,[["公开",1],["私人",2]]
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.