Class: DuckTesting::Type::Hash
- Defined in:
- lib/duck_testing/type/hash.rb
Instance Attribute Summary collapse
-
#key_types ⇒ Object
readonly
Returns the value of attribute key_types.
-
#value_types ⇒ Object
readonly
Returns the value of attribute value_types.
Instance Method Summary collapse
-
#initialize(key_types, value_types) ⇒ Hash
constructor
A new instance of Hash.
- #match?(object) ⇒ Boolean
- #to_s ⇒ String
Constructor Details
#initialize(key_types, value_types) ⇒ Hash
Returns a new instance of Hash.
10 11 12 13 |
# File 'lib/duck_testing/type/hash.rb', line 10 def initialize(key_types, value_types) @key_types = key_types @value_types = value_types end |
Instance Attribute Details
#key_types ⇒ Object (readonly)
Returns the value of attribute key_types.
6 7 8 |
# File 'lib/duck_testing/type/hash.rb', line 6 def key_types @key_types end |
#value_types ⇒ Object (readonly)
Returns the value of attribute value_types.
6 7 8 |
# File 'lib/duck_testing/type/hash.rb', line 6 def value_types @value_types end |
Instance Method Details
#match?(object) ⇒ Boolean
17 18 19 20 |
# File 'lib/duck_testing/type/hash.rb', line 17 def match?(object) return false unless object.is_a?(::Hash) match_keys?(object) && match_values?(object) end |
#to_s ⇒ String
23 24 25 |
# File 'lib/duck_testing/type/hash.rb', line 23 def to_s "Hash{#{key_types_to_s} => #{value_types_to_s}}" end |