Class: Slop::RangeOption Private

Inherits:
Option
  • Object
show all
Defined in:
lib/koota/cli.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#call(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (Slop::Error)


11
12
13
14
15
16
17
18
# File 'lib/koota/cli.rb', line 11

def call(value)
  split = value.split(',')

  raise Slop::Error, 'invalid range argument' if split.length.zero? || split.length > 2

  split.map!(&:to_i)
  split.length == 1 ? split[0] : split[0]..split[1]
end