Sha256: 96722cb8b37bf70bfe73f094b873e44ea3c0cbd3cf719b9b9a3e9778990b98ce

Contents?: true

Size: 441 Bytes

Versions: 6

Compression:

Stored size: 441 Bytes

Contents

module Rubycritic
  class Rating
    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

    def initialize(letter)
      @letter = letter
    end

    def to_s
      @letter
    end

    def to_h
      @letter
    end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubycritic-2.9.2 lib/rubycritic/core/rating.rb
rubycritic-2.9.1 lib/rubycritic/core/rating.rb
rubycritic-2.9.0 lib/rubycritic/core/rating.rb
rubycritic-2.8.0 lib/rubycritic/core/rating.rb
rubycritic-2.7.1 lib/rubycritic/core/rating.rb
rubycritic-2.7.0 lib/rubycritic/core/rating.rb