Sha256: f590d181d0b7d02622950920e974143c05318502a819925534a4f092f1715811

Contents?: true

Size: 371 Bytes

Versions: 1

Compression:

Stored size: 371 Bytes

Contents

require "json"

module FireAndForget
  module Utilities
    def to_arguments(params={})
      params.keys.sort { |a, b| a.to_s <=> b.to_s }.map do |key|
        %(--#{key}=#{to_parameter(params[key])})
      end.join(" ")
    end

    def to_parameter(obj)
      if obj.is_a?(String)
        obj
      else
        JSON.generate(obj)
      end.inspect
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fire_and_forget-0.2.0 lib/fire_and_forget/utilities.rb