class Ragol::OptionArguments

Constants

NEW_OPTIONS
OLD_OPTIONS
VAR_TYPES

Public Class Methods

new(origargs = Hash.new) click to toggle source
Calls superclass method
# File lib/ragol/args.rb, line 39
def initialize origargs = Hash.new
  super()

  if origargs[:arg]
    if re = origargs[:arg].find { |x| x.kind_of?(Regexp) }
      self[:valueregexp] = re
      self[:valuetype] = :regexp
    else
      self[:valuetype] = Ragol::HashUtil.hash_array_value VAR_TYPES, origargs[:arg]
    end
    
    self[:takesvalue] = if self[:valuetype] == :boolean
                          false
                        else
                          hasvaluetype = self[:valuetype] != nil
                          takes = { :optional => :optional, :required => true, :none => hasvaluetype, nil => hasvaluetype }
                          Ragol::HashUtil.hash_array_value takes, origargs[:arg]
                        end
  else
    Ragol::HashUtil.copy_hash self, origargs, [ [ :takesvalue, :valuereq ], [ :valuetype ], [ :valueregexp ] ]
    if self[:valuetype]
      self[:takesvalue] ||= true
    end
  end

  fields = [
            [ :regexps, :regexp, :res, :re ],
            [ :tags ],
            [ :process, :set ],
            [ :postproc ],
            [ :rcnames, :rcname, :rc ],
            [ :default ],
            [ :unsets, :unset ],
            [ :description ],
           ]
  Ragol::HashUtil.copy_hash self, origargs, fields
end