lib/rprogram/option.rb in rprogram-0.1.6 vs lib/rprogram/option.rb in rprogram-0.1.7

- old
+ new

@@ -15,30 +15,39 @@ # Does the option contain sub-options attr_reader :sub_options # - # Creates a new Option object with the specified _options_. If a _block_ + # Creates a new Option object with. If a _block_ # is given it will be used for the custom formating of the option. If a # _block_ is not given, the option will use the default_format when # generating the arguments. # - # _options_ must contain the following key: - # <tt>:flag</tt>:: The command-line flag to use. + # @param [Hash] options Additional options. + # @option options [String] :flag The command-line flag to use. + # @option options [true, false] :equals (false) + # Implies the option maybe + # formated as + # <tt>"--flag=value"</tt>. # - # _options_ may also contain the following keys: - # <tt>:equals</tt>:: Implies the option maybe formated as - # <tt>"--flag=value"</tt>. Defaults to +falue+, if - # not given. - # <tt>:multuple</tt>:: Specifies the option maybe given an Array of - # values. Defaults to +false+, if not given. - # <tt>:separator</tt>:: The separator to use for formating multiple - # arguments into one +String+. Cannot be used - # with <tt>:multiple</tt>. - # <tt>:sub_options</tt>:: Specifies that the option contains - # sub-options. Defaults to false, if not given. + # @option options [true, false] :multiple (false) + # Specifies the option maybe + # given an Array of values. + # @option options [String] :separator The separator to use for + # formating multiple arguments into + # one +String+. Cannot be used with + # the +:multiple+ option. + # @option options [true, false] :sub_options (false) + # Specifies that the option + # contains sub-options. # + # @yield [option, value] If a block is given, it will be used to format + # each value of the option. + # @yieldparam [Option] option The option that is being formatted. + # @yieldparam [String, Array] value The value to format for the + # option. May be an Array, if multiple + # values are allowed with the option. # def initialize(options={},&block) @flag = options[:flag] @equals = (options[:equals] || false) @@ -62,11 +71,14 @@ end end end # - # Returns an +Array+ of the arguments for the option with the specified - # _value_. + # Formats the arguments for the option. + # + # @param [Hash, Array, String] value The arguments to format. + # + # @return [Array] The formatted arguments of the option. # def arguments(value) return [@flag] if value == true return [] unless value