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, #remove_excluded_files, #round_to_tenths, #to_graph, verify_dependencies!
Constructor Details
#initialize(score, average_score, scanned_methods = []) ⇒ Page
Returns a new instance of Page.
148 149 150 151 152 |
# File 'lib/generators/flog.rb', line 148 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.
146 147 148 |
# File 'lib/generators/flog.rb', line 146 def average_score @average_score end |
#path ⇒ Object
Returns the value of attribute path.
146 147 148 |
# File 'lib/generators/flog.rb', line 146 def path @path end |
#scanned_methods ⇒ Object
Returns the value of attribute scanned_methods.
146 147 148 |
# File 'lib/generators/flog.rb', line 146 def scanned_methods @scanned_methods end |
#score ⇒ Object
Returns the value of attribute score.
146 147 148 |
# File 'lib/generators/flog.rb', line 146 def score @score end |
Instance Method Details
#filename ⇒ Object
154 155 156 |
# File 'lib/generators/flog.rb', line 154 def filename File.basename(path, ".txt") end |
#highest_score ⇒ Object
166 167 168 169 170 |
# File 'lib/generators/flog.rb', line 166 def highest_score scanned_methods.inject(0) do |highest, m| m.score > highest ? m.score : highest end end |
#to_h ⇒ Object
158 159 160 161 162 163 164 |
# File 'lib/generators/flog.rb', line 158 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 |