Class: Holoserve::Tool::Hash::Matcher
- Inherits:
-
Object
- Object
- Holoserve::Tool::Hash::Matcher
- Defined in:
- lib/holoserve/tool/hash/matcher.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#subset ⇒ Object
Returns the value of attribute subset.
Instance Method Summary collapse
-
#initialize(hash, subset) ⇒ Matcher
constructor
A new instance of Matcher.
- #match? ⇒ Boolean
Constructor Details
#initialize(hash, subset) ⇒ Matcher
Returns a new instance of Matcher.
7 8 9 |
# File 'lib/holoserve/tool/hash/matcher.rb', line 7 def initialize(hash, subset) @hash, @subset = hash, subset end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
4 5 6 |
# File 'lib/holoserve/tool/hash/matcher.rb', line 4 def hash @hash end |
#subset ⇒ Object
Returns the value of attribute subset.
5 6 7 |
# File 'lib/holoserve/tool/hash/matcher.rb', line 5 def subset @subset end |
Instance Method Details
#match? ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/holoserve/tool/hash/matcher.rb', line 11 def match? return false if @hash.length < @subset.length @subset.each do |key, value| if @hash.has_key?(key) return false unless match_value?(@hash[key], value) else return false end end true end |