Class: Yobi::FancyHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/yobi/fancy_hash.rb,
sig/yobi.rbs

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ FancyHash

Returns a new instance of FancyHash.

Parameters:

  • raw (Hash[String, untyped])


5
6
7
8
# File 'lib/yobi/fancy_hash.rb', line 5

def initialize(raw)
  super()
  replace(raw)
end

Instance Method Details

#inspectObject



10
11
12
# File 'lib/yobi/fancy_hash.rb', line 10

def inspect
  "#<#{self.class} #{super}>"
end

#pretty_print(q) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/yobi/fancy_hash.rb', line 14

def pretty_print(q)
  q.object_group(self) do
    each do |key, value|
      next if key == "message_type"

      value = public_send(key) if self.class.method_defined?(key, false)
      q.breakable
      q.text "#{key}="
      q.pp(value)
    end
  end
end