Sha256: c9818ca6ca1ac38af598f8d5f614dcf742beb2d2985d39d5c0c095050a74dc54
Contents?: true
Size: 674 Bytes
Versions: 1
Compression:
Stored size: 674 Bytes
Contents
require 'forwardable' module EnumeratedConstants extend Forwardable def all @all ||= constants.map(&method(:const_get)).delete_if do |constant| constant.is_a?(Array) end.freeze end def_delegators :all, :each, :include?, :map, :sample, :sort # Return all but the constant name you pass # @param name [Symbol,String] The name of the constant you don't want # @return [Array] @all except the value of that constant 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
enumerated_constants-0.2.0 | lib/enumerated_constants.rb |