Class: RProgram::Argument

Inherits:
Object
  • Object
show all
Defined in:
lib/rprogram/argument.rb

Direct Known Subclasses

NonOption, Option

Instance Method Summary collapse

Instance Method Details

#arguments(value) ⇒ Array

Formats a value into an Array of arguments.

Parameters:

  • value (Hash, Array, String)

    The value to format.

Returns:

  • (Array)

    The formatted arguments.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rprogram/argument.rb', line 13

def arguments(value)
  value = case value
          when Hash
            value.map do |key,sub_value|
              if    sub_value == true then key.to_s
              elsif sub_value         then "#{key}=#{sub_value}"
              end
            end
          when false, nil
            []
          else
            Array(value)
          end

  return value.compact
end