Module: Fmt::Matchable
Instance Method Summary collapse
-
#deconstruct ⇒ Object
Returns an Array representation of the object.
-
#deconstruct_keys(keys = []) ⇒ Object
Returns a Hash representation of the object limited to the given keys.
-
#to_h ⇒ Object
Hash representation of the Object (required for pattern matching).
Instance Method Details
#deconstruct ⇒ Object
Returns an Array representation of the object
22 23 24 |
# File 'lib/fmt/mixins/matchable.rb', line 22 def deconstruct to_h.values end |
#deconstruct_keys(keys = []) ⇒ Object
Returns a Hash representation of the object limited to the given keys
16 17 18 |
# File 'lib/fmt/mixins/matchable.rb', line 16 def deconstruct_keys(keys = []) to_h.select { _1 in keys } end |
#to_h ⇒ Object
Hash representation of the Object (required for pattern matching)
9 10 11 |
# File 'lib/fmt/mixins/matchable.rb', line 9 def to_h raise Error, "to_h must be implemented by including class" end |