Class: Yobi::FancyHash

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

Overview

Base class for every wrapper around one raw Restic JSON object.

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ FancyHash

Returns a new instance of FancyHash.

Parameters:

  • raw (Hash[String, untyped])


7
8
9
10
# File 'lib/yobi/fancy_hash.rb', line 7

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

Instance Method Details

#inspectString

Returns:

  • (String)


13
14
15
# File 'lib/yobi/fancy_hash.rb', line 13

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

#pretty_print(q) ⇒ void

This method returns an undefined value.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/yobi/fancy_hash.rb', line 18

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