Class: Swoop::Report

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entities, name = '', date = Time.now) ⇒ Report

Returns a new instance of Report.



7
8
9
10
11
12
13
14
15
16
# File 'lib/swoop/report.rb', line 7

def initialize(entities, name = '', date = Time.now)
  @entities = entities
  @date = date

  if name.nil? || name == ''
    @name = date.strftime("%d-%m-%Y")
  else
    @name = name
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#classes_countObject

Classes



23
24
25
# File 'lib/swoop/report.rb', line 23

def classes_count
  classes.count
end

#dateObject



18
19
20
# File 'lib/swoop/report.rb', line 18

def date
  @date.strftime("%d-%m-%Y")
end

#extensions_countObject

Extensions



71
72
73
# File 'lib/swoop/report.rb', line 71

def extensions_count
  extensions.count
end

#objc_classes_countObject



31
32
33
# File 'lib/swoop/report.rb', line 31

def objc_classes_count
  objc_classes.count
end

#objc_classes_percentageObject



40
41
42
43
# File 'lib/swoop/report.rb', line 40

def objc_classes_percentage
  return 0 if classes_count == 0
  (objc_classes_count.to_f / classes_count) * 100
end

#objc_extensions_countObject



79
80
81
# File 'lib/swoop/report.rb', line 79

def objc_extensions_count
  objc_extensions.count
end

#objc_extensions_percentageObject



88
89
90
91
# File 'lib/swoop/report.rb', line 88

def objc_extensions_percentage
  return 0 if extensions_count == 0
  (objc_extensions_count.to_f / extensions_count) * 100
end

#objc_structs_countObject



55
56
57
# File 'lib/swoop/report.rb', line 55

def objc_structs_count
  objc_structs.count
end

#objc_structs_percentageObject



64
65
66
67
# File 'lib/swoop/report.rb', line 64

def objc_structs_percentage
  return 0 if structs_count == 0
  (objc_structs_count.to_f / structs_count) * 100
end

#structs_countObject

Structs



47
48
49
# File 'lib/swoop/report.rb', line 47

def structs_count
  structs.count
end

#swift_classes_countObject



27
28
29
# File 'lib/swoop/report.rb', line 27

def swift_classes_count
  swift_classes.count
end

#swift_classes_percentageObject



35
36
37
38
# File 'lib/swoop/report.rb', line 35

def swift_classes_percentage
  return 0 if classes_count == 0
  (swift_classes_count.to_f / classes_count) * 100
end

#swift_extensions_countObject



75
76
77
# File 'lib/swoop/report.rb', line 75

def swift_extensions_count
  swift_extensions.count
end

#swift_extensions_percentageObject



83
84
85
86
# File 'lib/swoop/report.rb', line 83

def swift_extensions_percentage
  return 0 if extensions_count == 0
  (swift_extensions_count.to_f / extensions_count) * 100
end

#swift_structs_countObject



51
52
53
# File 'lib/swoop/report.rb', line 51

def swift_structs_count
  swift_structs.count
end

#swift_structs_percentageObject



59
60
61
62
# File 'lib/swoop/report.rb', line 59

def swift_structs_percentage
  return 0 if structs_count == 0
  (swift_structs_count.to_f / structs_count) * 100
end

#to_sObject



93
94
95
96
97
# File 'lib/swoop/report.rb', line 93

def to_s
  "Class | swift : #{swift_classes_count} (#{'%.02f' % swift_classes_percentage}%) , objc : #{objc_classes_count} (#{'%.02f' % objc_classes_percentage}%), total: #{classes_count} \n" +
  "Structs | swift : #{swift_structs_count} (#{'%.02f' % swift_structs_percentage}%) , objc : #{objc_structs_count} (#{'%.02f' % objc_structs_percentage}%), total: #{structs_count} \n" +
  "Extensions | swift : #{swift_extensions_count} (#{'%.02f' % swift_extensions_percentage}%) , objc : #{objc_extensions_count} (#{'%.02f' % objc_extensions_percentage}%), total: #{extensions_count}"
end