class Nutriscore::Common::ScoreClassRange

Range of possible score classes.

This is a standard Ruby {{::Range}} for {{String}}s with some additional helper methods, similar to {{Nutriscore::Common::Range}} (without the computation parts).

Public Instance Methods

==(a) click to toggle source
Calls superclass method
# File lib/nutriscore/common/score_class_range.rb, line 8
def ==(a)
  if String === a
    single == a
  else
    super
  end
end
inspect() click to toggle source
# File lib/nutriscore/common/score_class_range.rb, line 24
def inspect
  to_s
end
single() click to toggle source

Returns single value if possible, nil if there is a range of values.

# File lib/nutriscore/common/score_class_range.rb, line 29
def single
  min if min == max
end
to_s() click to toggle source
Calls superclass method
# File lib/nutriscore/common/score_class_range.rb, line 16
def to_s
  if min == max
    min.to_s
  else
    super
  end
end