Sha256: ee8d20eb51cd2ed8f9514af6ff73626d649eff2a11bdffd1d2f5bf2217ba3f05

Contents?: true

Size: 409 Bytes

Versions: 3

Compression:

Stored size: 409 Bytes

Contents

module Kosher
  class Condition < Struct.new(:in_words)
    def to_i
      case in_words
      when 'new'
        1
      when 'mint'
        2
      when 'verygood'
        3
      when 'good'
        4
      when 'acceptable'
        5
      else
        6
      end
    end

    def kosher?
      to_i <= 4
    end

    def new?
      in_words == 'new'
    end

    def used?
      !new?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kosher-0.1.2 lib/kosher/condition.rb
kosher-0.1.1 lib/kosher/condition.rb
kosher-0.1.0 lib/kosher/condition.rb