Sha256: 9f636165c30882c84b0cd496a318eed30cfcc5e971e1af7628457807d49f1378

Contents?: true

Size: 492 Bytes

Versions: 3

Compression:

Stored size: 492 Bytes

Contents

# frozen_string_literal: true

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(*options)
      to_h.to_json(*options)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubycritic-4.9.1 lib/rubycritic/core/rating.rb
rubycritic-4.9.0 lib/rubycritic/core/rating.rb
rubycritic-4.8.1 lib/rubycritic/core/rating.rb