Module: EnumeratedConstants
- Extended by:
- Forwardable
- Defined in:
- lib/enumerated_constants.rb
Instance Method Summary collapse
- #all ⇒ Object
-
#except(*names) ⇒ Array
Return all but the constant name you pass.
Instance Method Details
#all ⇒ Object
6 7 8 9 10 |
# File 'lib/enumerated_constants.rb', line 6 def all @all ||= constants.map(&method(:const_get)).delete_if do |constant| constant.is_a?(Array) end.freeze end |
#except(*names) ⇒ Array
Return all but the constant name you pass
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/enumerated_constants.rb', line 17 def except(*names) const_names = names = names.map(&:upcase).map(&:to_sym) values = names.map do |name| begin const_get(name) rescue NameError end end.compact all - values end |