Class: Rubycrap::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycrap/reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(crap_methods) ⇒ Reporter

Returns a new instance of Reporter.



6
7
8
9
# File 'lib/rubycrap/reporter.rb', line 6

def initialize(crap_methods)
  @crap_methods = crap_methods
  @crap_methods_by_score = crap_methods.sort_by { |k| -k[:crap_score] }
end

Instance Attribute Details

#crap_methodsObject (readonly)

Returns the value of attribute crap_methods.



4
5
6
# File 'lib/rubycrap/reporter.rb', line 4

def crap_methods
  @crap_methods
end

#crap_methods_by_scoreObject (readonly)

Returns the value of attribute crap_methods_by_score.



4
5
6
# File 'lib/rubycrap/reporter.rb', line 4

def crap_methods_by_score
  @crap_methods_by_score
end

Instance Method Details

#consoleObject



15
16
17
18
19
# File 'lib/rubycrap/reporter.rb', line 15

def console
  crap_methods_by_score[0..10].each do |element|
    puts formated_result(element)
  end
end

#htmlObject



11
12
13
# File 'lib/rubycrap/reporter.rb', line 11

def html
  File.open("CRAP.html", 'w') { |file| file.write(build_html) }
end