Class: RubyCritic::Rating
- Inherits:
-
Object
- Object
- RubyCritic::Rating
- Defined in:
- lib/rubycritic/core/rating.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(letter) ⇒ Rating
constructor
A new instance of Rating.
- #to_h ⇒ Object
- #to_json(*options) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(letter) ⇒ Rating
Returns a new instance of Rating.
15 16 17 |
# File 'lib/rubycritic/core/rating.rb', line 15 def initialize(letter) @letter = letter end |
Class Method Details
.from_cost(cost) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/rubycritic/core/rating.rb', line 5 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_h ⇒ Object
23 24 25 |
# File 'lib/rubycritic/core/rating.rb', line 23 def to_h @letter end |
#to_json(*options) ⇒ Object
27 28 29 |
# File 'lib/rubycritic/core/rating.rb', line 27 def to_json(*) to_h.to_json(*) end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/rubycritic/core/rating.rb', line 19 def to_s @letter end |