Class: Slop

Inherits:
Object
  • Object
show all
Defined in:
lib/parser/compatibility/slop.rb

Overview

Instance Method Summary collapse

Instance Method Details

#extract_long_flag(objects, config) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/parser/compatibility/slop.rb', line 3

def extract_long_flag(objects, config)
  flag = objects.first.to_s
  if flag =~ /\A(?:--?)?[a-zA-Z0-9][a-zA-Z0-9_.-]+\=?\??\z/
    config[:argument] ||= true if flag.end_with?('=')
    config[:optional_argument] = true if flag.end_with?('=?')
    objects.shift
    clean(flag).sub(/\=\??\z/, '')
  end
end