Class: Parlour::Types::Hash
Overview
A hash with known key and value types.
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #describe ⇒ Object
- #generate_rbi ⇒ Object
- #generate_rbs ⇒ Object
-
#initialize(key, value) ⇒ Hash
constructor
A new instance of Hash.
Methods inherited from Type
Constructor Details
#initialize(key, value) ⇒ Hash
Returns a new instance of Hash.
336 337 338 339 |
# File 'lib/parlour/types.rb', line 336 def initialize(key, value) @key = to_type(key) @value = to_type(value) end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
347 348 349 |
# File 'lib/parlour/types.rb', line 347 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
350 351 352 |
# File 'lib/parlour/types.rb', line 350 def value @value end |
Instance Method Details
#==(other) ⇒ Object
342 343 344 |
# File 'lib/parlour/types.rb', line 342 def ==(other) Hash === other && key == other.key && value == other.value end |
#describe ⇒ Object
363 364 365 |
# File 'lib/parlour/types.rb', line 363 def describe "Hash<#{key.describe}, #{value.describe}>" end |
#generate_rbi ⇒ Object
353 354 355 |
# File 'lib/parlour/types.rb', line 353 def generate_rbi "T::Hash[#{key.generate_rbi}, #{value.generate_rbi}]" end |
#generate_rbs ⇒ Object
358 359 360 |
# File 'lib/parlour/types.rb', line 358 def generate_rbs "::Hash[#{key.generate_rbs}, #{value.generate_rbs}]" end |