class SimpleEnum::Enum
Attributes
hash[R]
name[R]
Public Class Methods
new(name, hash)
click to toggle source
# File lib/simple_enum/enum.rb, line 7 def initialize(name, hash) @name = name.to_s @hash = hash end
Public Instance Methods
each_pair(&block)
click to toggle source
# File lib/simple_enum/enum.rb, line 32 def each_pair(&block) hash.each_pair(&block) end
Also aliased as: each
fetch(key)
click to toggle source
# File lib/simple_enum/enum.rb, line 28 def fetch(key) value(key) || raise("Key \"#{key}\" not found") end
include?(key)
click to toggle source
# File lib/simple_enum/enum.rb, line 12 def include?(key) hash.key?(key.to_s) || hash.value?(key) end
key(value)
click to toggle source
# File lib/simple_enum/enum.rb, line 16 def key(value) key = hash.key(value) key.to_sym if key end
keys()
click to toggle source
# File lib/simple_enum/enum.rb, line 41 def keys hash.keys end
map(&block)
click to toggle source
# File lib/simple_enum/enum.rb, line 37 def map(&block) hash.map(&block) end
to_s()
click to toggle source
# File lib/simple_enum/enum.rb, line 54 def to_s name end
value(key)
click to toggle source
# File lib/simple_enum/enum.rb, line 21 def value(key) value = hash[key.to_s] value = key if hash.value?(key) value end
Also aliased as: []
values()
click to toggle source
# File lib/simple_enum/enum.rb, line 45 def values hash.values end
values_at(*keys)
click to toggle source
# File lib/simple_enum/enum.rb, line 49 def values_at(*keys) keys = keys.map(&:to_s) hash.values_at(*keys) end