Class: MetricFu::Flog::Page
- Defined in:
- lib/generators/flog.rb
Instance Attribute Summary collapse
-
#average_score ⇒ Object
Returns the value of attribute average_score.
-
#path ⇒ Object
Returns the value of attribute path.
-
#scanned_methods ⇒ Object
Returns the value of attribute scanned_methods.
-
#score ⇒ Object
Returns the value of attribute score.
Attributes inherited from Generator
Instance Method Summary collapse
- #filename ⇒ Object
- #highest_score ⇒ Object
-
#initialize(score, average_score, scanned_methods = []) ⇒ Page
constructor
A new instance of Page.
- #to_h ⇒ Object
Methods inherited from Generator
#analyze, class_name, #create_data_dir_if_missing, #create_metric_dir_if_missing, #create_output_dir_if_missing, #emit, generate_report, #generate_report, #metric_directory, metric_directory, #round_to_tenths, #to_graph, verify_dependencies!
Constructor Details
#initialize(score, average_score, scanned_methods = []) ⇒ Page
Returns a new instance of Page.
116 117 118 119 120 |
# File 'lib/generators/flog.rb', line 116 def initialize(score, average_score, scanned_methods = []) @score = score.to_f @scanned_methods = scanned_methods @average_score = average_score.to_f end |
Instance Attribute Details
#average_score ⇒ Object
Returns the value of attribute average_score.
114 115 116 |
# File 'lib/generators/flog.rb', line 114 def average_score @average_score end |
#path ⇒ Object
Returns the value of attribute path.
114 115 116 |
# File 'lib/generators/flog.rb', line 114 def path @path end |
#scanned_methods ⇒ Object
Returns the value of attribute scanned_methods.
114 115 116 |
# File 'lib/generators/flog.rb', line 114 def scanned_methods @scanned_methods end |
#score ⇒ Object
Returns the value of attribute score.
114 115 116 |
# File 'lib/generators/flog.rb', line 114 def score @score end |
Instance Method Details
#filename ⇒ Object
122 123 124 |
# File 'lib/generators/flog.rb', line 122 def filename File.basename(path, ".txt") end |
#highest_score ⇒ Object
134 135 136 137 138 |
# File 'lib/generators/flog.rb', line 134 def highest_score scanned_methods.inject(0) do |highest, m| m.score > highest ? m.score : highest end end |
#to_h ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/generators/flog.rb', line 126 def to_h {:score => @score, :scanned_methods => @scanned_methods.map {|sm| sm.to_h}, :highest_score => highest_score, :average_score => average_score, :path => path} end |