Class: Slop::ArrayOption

Inherits:
Option
  • Object
show all
Defined in:
lib/slop/types.rb

Overview

Collect multiple items into a single Array. Support arguments separated by commas or multiple occurences.

Constant Summary

Constants inherited from Option

Option::DEFAULT_CONFIG

Instance Attribute Summary

Attributes inherited from Option

#block, #config, #count, #desc, #flags, #value

Instance Method Summary collapse

Methods inherited from Option

#ensure_call, #expects_argument?, #finish, #flag, #help?, #initialize, #key, #null?, #reset, #suppress_errors?, #tail, #tail?, #to_s

Constructor Details

This class inherits a constructor from Slop::Option

Instance Method Details

#call(value) ⇒ Object


46
47
48
49
# File 'lib/slop/types.rb', line 46

def call(value)
  @value ||= []
  @value.concat value.split(delimiter, limit)
end

#default_valueObject


51
52
53
# File 'lib/slop/types.rb', line 51

def default_value
  config[:default] || []
end

#delimiterObject


55
56
57
# File 'lib/slop/types.rb', line 55

def delimiter
  config[:delimiter] || ","
end

#limitObject


59
60
61
# File 'lib/slop/types.rb', line 59

def limit
  config[:limit] || 0
end