Class: Norman::KeyIterator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/norman/abstract_key_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keys, &callable) ⇒ KeyIterator

Returns a new instance of KeyIterator.



97
98
99
100
# File 'lib/norman/abstract_key_set.rb', line 97

def initialize(keys, &callable)
  @keys     = keys
  @callable = callable
end

Instance Attribute Details

#callableObject (readonly)

Returns the value of attribute callable.



95
96
97
# File 'lib/norman/abstract_key_set.rb', line 95

def callable
  @callable
end

#keysObject (readonly)

Returns the value of attribute keys.



95
96
97
# File 'lib/norman/abstract_key_set.rb', line 95

def keys
  @keys
end

Instance Method Details

#each(&block) ⇒ Object



102
103
104
# File 'lib/norman/abstract_key_set.rb', line 102

def each(&block)
  block_given? ? keys.each {|k| yield callable.call(k)} : to_enum
end