Class: RubyCritic::Rating

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycritic/core/rating.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(letter) ⇒ Rating

Returns a new instance of Rating.



12
13
14
# File 'lib/rubycritic/core/rating.rb', line 12

def initialize(letter)
  @letter = letter
end

Class Method Details

.from_cost(cost) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/rubycritic/core/rating.rb', line 3

def self.from_cost(cost)
  if    cost <= 2  then new('A')
  elsif cost <= 4  then new('B')
  elsif cost <= 8  then new('C')
  elsif cost <= 16 then new('D')
  else new('F')
  end
end

Instance Method Details

#to_hObject



20
21
22
# File 'lib/rubycritic/core/rating.rb', line 20

def to_h
  @letter
end

#to_json(*a) ⇒ Object



24
25
26
# File 'lib/rubycritic/core/rating.rb', line 24

def to_json(*a)
  to_h.to_json(*a)
end

#to_sObject



16
17
18
# File 'lib/rubycritic/core/rating.rb', line 16

def to_s
  @letter
end