lib/slop/option.rb in slop-0.1.4 vs lib/slop/option.rb in slop-0.1.5
- old
+ new
@@ -1,15 +1,34 @@
class Slop
class Option
+ # @return [Symbol,#to_s]
attr_reader :flag
+
+ # @return [Symbol,#to_s]
attr_reader :option
+
+ # @return [String]
attr_reader :description
- attr_reader :argument_value
+
+ # @return [Object]
attr_reader :default
+
+ # @return [Proc]
attr_reader :callback
+ # @param [Hash] options Option attributes
+ # @option options [Symbol,#to_s] :flag
+ # @option options [Symbol,#to_s] :option
+ # @option options [Symbol,#to_s] :description
+ # @option options [Boolean] :argument
+ # @option options [Boolean] :optional
+ # @option options [Object] :default
+ # @option options [Object] :as
+ # @option options [Proc] :callback
+ # @option options [String,#to_s] :delimiter
+ # @option options [Integer] :limit
def initialize(options={}, &blk)
@options = options
@flag = options[:flag]
@option = options[:option] || options[:opt]
@description = options[:description] || options[:desc]
@@ -20,11 +39,11 @@
@as = options[:as]
@callback = options[:callback]
# Array properties
@delimiter = options[:delimiter] || ','
- @limit = options[:limit] || 1
+ @limit = options[:limit] || 0
@argument_value = nil
end
# Set the argument value
@@ -104,10 +123,10 @@
# option :v, :verbose, :default => false, :switch => true
#
# Now when the `-v` or `--verbose` option is supplied, verbose will
# be set to `true`, rather than the default `false` option
def switch_argument_value
- @argument_value = @option[:switch]
+ @argument_value = @options[:switch]
end
# return a key for an option, prioritize
# option before flag as it's more descriptive
def key
\ No newline at end of file