Module: Argvise::HashMixin

Defined in:
lib/argvise/core.rb

Overview

Converts a hash map into command-line arguments.

Monkey Patching:

  • Hash#to_argv
  • Hash#to_argv_bsd

Examples:


require 'argvise'

module A
  module_function
  include Argvise::HashMixin

  def demo
    puts({ path: '/path/to/dir' }.to_argv)
    #=> ["--path", "/path/to/dir"]

    puts({ path: '/path/to/dir' }.to_argv_bsd)
    #=> ["-path", "/path/to/dir"]
  end
end

A.demo
Hash.method_defined?(:to_argv) # => true
{}.respond_to?(:to_argv) #=> true