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



63
64
65
66
# File 'lib/slop/types.rb', line 63

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

#default_valueObject



68
69
70
# File 'lib/slop/types.rb', line 68

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

#delimiterObject



72
73
74
# File 'lib/slop/types.rb', line 72

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

#limitObject



76
77
78
# File 'lib/slop/types.rb', line 76

def limit
  config[:limit] || 0
end