Class: HashMap::AfterEachContext
- Inherits:
-
Object
- Object
- HashMap::AfterEachContext
- Defined in:
- lib/hash_map/after_each_context.rb
Instance Attribute Summary collapse
-
#original ⇒ Object
readonly
Returns the value of attribute original.
-
#struct ⇒ Object
readonly
Returns the value of attribute struct.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #block? ⇒ Boolean
- #has_key? ⇒ Boolean
-
#initialize(original, struct, value) ⇒ AfterEachContext
constructor
A new instance of AfterEachContext.
- #provided? ⇒ Boolean
Constructor Details
#initialize(original, struct, value) ⇒ AfterEachContext
Returns a new instance of AfterEachContext.
4 5 6 7 8 |
# File 'lib/hash_map/after_each_context.rb', line 4 def initialize(original, struct, value) @original = original @struct = struct @value = value end |
Instance Attribute Details
#original ⇒ Object (readonly)
Returns the value of attribute original.
3 4 5 |
# File 'lib/hash_map/after_each_context.rb', line 3 def original @original end |
#struct ⇒ Object (readonly)
Returns the value of attribute struct.
3 4 5 |
# File 'lib/hash_map/after_each_context.rb', line 3 def struct @struct end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/hash_map/after_each_context.rb', line 3 def value @value end |
Instance Method Details
#block? ⇒ Boolean
14 15 16 |
# File 'lib/hash_map/after_each_context.rb', line 14 def block? !!struct[:proc] end |
#has_key? ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hash_map/after_each_context.rb', line 18 def has_key? return true if block? found = true struct[:from].reduce(original) do |prv, nxt| unless prv.respond_to?(:key?) && prv.key?(nxt) found = false break end prv.send(:[], nxt) end found end |
#provided? ⇒ Boolean
10 11 12 |
# File 'lib/hash_map/after_each_context.rb', line 10 def provided? has_key? end |