Sha256: 27acb519fb7b534e564702ed4789fdf85c8ce3210496b8acc3f31e612edaa47f

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

module RProgram
  class Argument

    #
    # Formats a value into an Array of arguments.
    #
    # @param [Hash, Array, String] value
    #   The value to format.
    #
    # @return [Array]
    #   The formatted arguments.
    #
    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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rprogram-0.3.2 lib/rprogram/argument.rb