Class: SnapshotArchive::Formatters::Show

Inherits:
Object
  • Object
show all
Defined in:
lib/snapshot_archive/formatters.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata) ⇒ Show

Returns a new instance of Show.



29
30
31
# File 'lib/snapshot_archive/formatters.rb', line 29

def initialize()
  @metadata = 
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



28
29
30
# File 'lib/snapshot_archive/formatters.rb', line 28

def 
  @metadata
end

Class Method Details

.call(metadata) ⇒ Object



24
25
26
# File 'lib/snapshot_archive/formatters.rb', line 24

def self.call()
  new().call
end

Instance Method Details

#callObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/snapshot_archive/formatters.rb', line 33

def call
  id = .fetch("id")
  timestamp = Time.parse(.fetch("timestamp")).strftime("%F %H:%M")
  message = .fetch("message")
  dir = .fetch("dir")

  Cfg.shell.puts(<<~TXT)
    id: #{id}
    time: #{timestamp}
    path: #{dir}
    ----------------------
    #{message}

    Full metadata:
    #{JSON.pretty_generate(.dig("archive", "stores"))}
  TXT
end