Class: Nutriscore::Common::ScoreClassRange
- Inherits:
-
Range
- Object
- Range
- Nutriscore::Common::ScoreClassRange
- Defined in:
- lib/nutriscore/common/score_class_range.rb
Overview
Range of possible score classes.
This is a standard Ruby {{::Range} for {String}s with some additional helper methods, similar to {Nutriscore{Nutriscore::Common{Nutriscore::Common::Range} (without the computation parts).
Instance Method Summary collapse
- #==(a) ⇒ Object
- #inspect ⇒ Object
-
#single ⇒ Object
Returns single value if possible,
nil
if there is a range of values. - #to_s ⇒ Object
Instance Method Details
#==(a) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/nutriscore/common/score_class_range.rb', line 8 def ==(a) if String === a single == a else super end end |
#inspect ⇒ Object
24 25 26 |
# File 'lib/nutriscore/common/score_class_range.rb', line 24 def inspect to_s end |
#single ⇒ Object
Returns single value if possible, nil
if there is a range of values.
29 30 31 |
# File 'lib/nutriscore/common/score_class_range.rb', line 29 def single min if min == max end |
#to_s ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/nutriscore/common/score_class_range.rb', line 16 def to_s if min == max min.to_s else super end end |