Class: DomesticateMonkeys::View

Inherits:
Object
  • Object
show all
Defined in:
lib/domesticate_monkeys/constants/view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(snapshot = nil) ⇒ View

Returns a new instance of View.



7
8
9
# File 'lib/domesticate_monkeys/constants/view.rb', line 7

def initialize(snapshot = nil)
  @snapshot = snapshot || Snapshot.new
end

Instance Attribute Details

#snapshotObject (readonly)

Returns the value of attribute snapshot.



5
6
7
# File 'lib/domesticate_monkeys/constants/view.rb', line 5

def snapshot
  @snapshot
end

Instance Method Details

#all(path_filter = nil) ⇒ Object

parsed CLI option methods



13
14
15
16
17
18
19
20
21
# File 'lib/domesticate_monkeys/constants/view.rb', line 13

def all(path_filter = nil)
  tracks = @snapshot.multi_tracks
  tracks = filter_tracks_by_path(tracks, path_filter) if path_filter

  tracks.values.each { |track| track.print }

  # Return nil in order to avoid a lengthy print of the @snapshot.
  return nil
end

#appObject



23
24
25
# File 'lib/domesticate_monkeys/constants/view.rb', line 23

def app
  all(app_name)
end

#overviewObject



27
28
29
30
31
32
33
34
35
# File 'lib/domesticate_monkeys/constants/view.rb', line 27

def overview
  app_header = header_text("#{app_monkeys_count} Monkeys within our own application").red
  puts app_header
  app

  all_header = header_text("#{all_monkeys_count} Monkeys through the whole application, including third party software").yellow
  puts all_header
  all
end