Method: DurationRange#initialize
- Defined in:
- lib/timespan/core_ext/range.rb
#initialize(range, unit = :minutes) ⇒ DurationRange
Returns a new instance of DurationRange.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/timespan/core_ext/range.rb', line 25 def initialize range, unit = :minutes range = (0..60) if range.min == nil || range.max == nil super(range, except: %w{to_s to_str}) unit = unit.to_s.pluralize.to_sym unless allowed_unit? unit raise ArgumentError, "Unit #{unit} not valid, only: #{allowed_units} are valid" end @unit = unit @range = range end |