Class: ParsableHash::HashStrategy
- Inherits:
-
Object
- Object
- ParsableHash::HashStrategy
- Includes:
- Enumerable
- Defined in:
- lib/parsable_hash/hash_strategy.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#origin_hash ⇒ Object
Returns the value of attribute origin_hash.
Instance Method Summary collapse
- #clean_for_hash!(value_hash) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(strategy, origin_hash = nil) ⇒ HashStrategy
constructor
A new instance of HashStrategy.
Constructor Details
#initialize(strategy, origin_hash = nil) ⇒ HashStrategy
Returns a new instance of HashStrategy.
8 9 10 11 12 13 |
# File 'lib/parsable_hash/hash_strategy.rb', line 8 def initialize(strategy, origin_hash = nil) @hash = prepare(strategy) self.origin_hash = origin_hash clean_for_hash!(origin_hash) unless origin_hash.nil? end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
5 6 7 |
# File 'lib/parsable_hash/hash_strategy.rb', line 5 def hash @hash end |
#origin_hash ⇒ Object
Returns the value of attribute origin_hash.
6 7 8 |
# File 'lib/parsable_hash/hash_strategy.rb', line 6 def origin_hash @origin_hash end |
Instance Method Details
#clean_for_hash!(value_hash) ⇒ Object
19 20 21 |
# File 'lib/parsable_hash/hash_strategy.rb', line 19 def clean_for_hash!(value_hash) @hash = clean_pairs(@hash, value_hash) end |
#each(&block) ⇒ Object
15 16 17 |
# File 'lib/parsable_hash/hash_strategy.rb', line 15 def each(&block) hash.each { |strategy| yield strategy } end |