Class: GetArgs::Argument

Inherits:
Object
  • Object
show all
Defined in:
lib/argument_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg_array) ⇒ Argument

Returns a new instance of Argument.



15
16
17
18
# File 'lib/argument_list.rb', line 15

def initialize(arg_array)
  @optional = arg_array.length > 1
  @name, @default = *arg_array
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



13
14
15
# File 'lib/argument_list.rb', line 13

def default
  @default
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/argument_list.rb', line 13

def name
  @name
end

Instance Method Details

#multiple?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/argument_list.rb', line 24

def multiple?
  name.to_s.slice(0,1) == '*'
end

#optional?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/argument_list.rb', line 20

def optional?
  @optional
end

#to_sObject



28
29
30
# File 'lib/argument_list.rb', line 28

def to_s
  name
end