Class: DomesticateMonkeys::Report

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReport

Returns a new instance of Report.



7
8
9
10
11
12
13
14
# File 'lib/domesticate_monkeys/constants/report.rb', line 7

def initialize
  @snapshot     = Snapshot.new
  @all_tracks   = @snapshot.all_tracks
  @multi_tracks = @snapshot.multi_tracks

  @method_count           = @all_tracks.size
  @redefined_method_count = @multi_tracks.size
end

Instance Attribute Details

#all_tracksObject (readonly)

Returns the value of attribute all_tracks.



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

def all_tracks
  @all_tracks
end

#method_countObject (readonly)

Returns the value of attribute method_count.



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

def method_count
  @method_count
end

#multi_tracksObject (readonly)

Returns the value of attribute multi_tracks.



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

def multi_tracks
  @multi_tracks
end

#redefined_method_countObject (readonly)

Returns the value of attribute redefined_method_count.



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

def redefined_method_count
  @redefined_method_count
end

#snapshotObject (readonly)

Returns the value of attribute snapshot.



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

def snapshot
  @snapshot
end

Instance Method Details

#boot_informationObject



23
24
25
26
27
28
# File 'lib/domesticate_monkeys/constants/report.rb', line 23

def boot_information
  plain_text   = "It took domesticate_monkeys #{$BOOT_TIME} seconds to analyse your application,"\
                 " which defined #{$DOMESTICATE_MONKEYS_COUNT} methods."
  colored_text = "\e[#{35}m#{plain_text}\e[0m"
  puts colored_text   
end

#inspectObject



30
31
32
33
34
35
# File 'lib/domesticate_monkeys/constants/report.rb', line 30

def inspect
  # Overwrite default behaviour, which returns – and thus often prints –
  # the values of the object's set instance variables, which is enormous
  # in the case of @all_tracks and @multi_tracks. 
  to_s
end

#top_redefinitions(top_amount = 3) ⇒ Object



16
17
18
19
20
21
# File 'lib/domesticate_monkeys/constants/report.rb', line 16

def top_redefinitions(top_amount = 3)
  puts "Showing top #{top_amount} redefinitions:"
  tracks = @multi_tracks.first(top_amount).to_h.values
  tracks.each(&:print)
  nil
end