Class: MetricFu::Flog::Page

Inherits:
Generator show all
Defined in:
lib/generators/flog.rb

Instance Attribute Summary collapse

Attributes inherited from Generator

#report, #template

Instance Method Summary collapse

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_scoreObject

Returns the value of attribute average_score


146
147
148
# File 'lib/generators/flog.rb', line 146

def average_score
  @average_score
end

#pathObject

Returns the value of attribute path


146
147
148
# File 'lib/generators/flog.rb', line 146

def path
  @path
end

#scanned_methodsObject

Returns the value of attribute scanned_methods


146
147
148
# File 'lib/generators/flog.rb', line 146

def scanned_methods
  @scanned_methods
end

#scoreObject

Returns the value of attribute score


146
147
148
# File 'lib/generators/flog.rb', line 146

def score
  @score
end

Instance Method Details

#filenameObject


154
155
156
# File 'lib/generators/flog.rb', line 154

def filename 
  File.basename(path, ".txt") 
end

#highest_scoreObject


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_hObject


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