Sha256: 813a419625c6f415c48c98a034623fd6a7a8a741b9e670eaece64bea971d256c
Contents?: true
Size: 1.01 KB
Versions: 4
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module Kind module Enum METHODS = \ <<-RUBY def to_h ENUM__HASH end def items ENUM__ITEMS end def ===(arg) ENUM__ITEMS.any? { |item| item === arg } end def refs ENUM__REFS.to_a end def keys ENUM__KEYS.to_a end def values ENUM__VALS.to_a end def ref?(arg) ENUM__REFS.include?(arg) end def key?(arg) arg.respond_to?(:to_sym) ? ENUM__KEYS.member?(arg.to_s) : false end def value?(arg) ENUM__VALS.include?(arg) end def [](arg) return arg if ref?(arg) raise KeyError, "key or value not found: %p" % [arg] end def ref(arg) arg if ref?(arg) end def item(arg) ENUM__MAP[arg] end def key(arg) item(arg).key if value?(arg) end def value_at(arg) item(arg).value if key?(arg) end def self.included(base) base.extend(base) end RUBY private_constant :METHODS end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kind-5.10.0 | lib/kind/enum/methods.rb |
kind-5.9.0 | lib/kind/enum/methods.rb |
kind-5.8.1 | lib/kind/enum/methods.rb |
kind-5.8.0 | lib/kind/enum/methods.rb |