Sha256: 5b93fde5bf7b0fcc2daccca9ed87c2bb2143e62e252728fbce6dcc914e465a29

Contents?: true

Size: 471 Bytes

Versions: 1

Compression:

Stored size: 471 Bytes

Contents

require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/string/inflections'

module RdiffSimple
  class OptionsParser
    def self.parse(*args)
      options = args.extract_options!

      flags = args.map { |flag| flag.size == 1 ? "-#{flag}" : "--#{flag}" } * ' '
      arguments = options.map { |key, value| (key.size == 1 ? "-#{key}" : "--#{key}") + " #{value}" } * ' '

      "#{flags} #{arguments}".dasherize.strip
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rdiff-simple-0.1.3 lib/rdiff_simple/options_parser.rb