Class: CLASP::Arguments::FlagArgument

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

Overview

:nodoc: all

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg, given_index, given_name, resolved_name, argument_alias, given_hyphens, given_label, extras) ⇒ FlagArgument

:nodoc:



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/clasp/arguments.rb', line 69

def initialize(arg, given_index, given_name, resolved_name, argument_alias, given_hyphens, given_label, extras)

  @arg     = arg
  @given_index = given_index
  @given_name    = given_name
  @argument_alias  =  argument_alias
  @given_hyphens = given_hyphens
  @given_label = given_label
  @name      =  resolved_name || given_name
  @extras      =  extras.nil? ? {} : extras
end

Instance Attribute Details

#argument_aliasObject (readonly)

Returns the value of attribute argument_alias.



83
84
85
# File 'lib/clasp/arguments.rb', line 83

def argument_alias
  @argument_alias
end

#extrasObject (readonly)

Returns the value of attribute extras.



87
88
89
# File 'lib/clasp/arguments.rb', line 87

def extras
  @extras
end

#given_hyphensObject (readonly)

Returns the value of attribute given_hyphens.



84
85
86
# File 'lib/clasp/arguments.rb', line 84

def given_hyphens
  @given_hyphens
end

#given_indexObject (readonly)

Returns the value of attribute given_index.



81
82
83
# File 'lib/clasp/arguments.rb', line 81

def given_index
  @given_index
end

#given_labelObject (readonly)

Returns the value of attribute given_label.



85
86
87
# File 'lib/clasp/arguments.rb', line 85

def given_label
  @given_label
end

#given_nameObject (readonly)

Returns the value of attribute given_name.



82
83
84
# File 'lib/clasp/arguments.rb', line 82

def given_name
  @given_name
end

#nameObject (readonly)

Returns the value of attribute name.



86
87
88
# File 'lib/clasp/arguments.rb', line 86

def name
  @name
end

Instance Method Details

#==(rhs) ⇒ Object

:nodoc:



107
108
109
110
111
112
113
114
115
# File 'lib/clasp/arguments.rb', line 107

def ==(rhs)

  return false if rhs.nil?
  if not rhs.instance_of? String

    rhs = rhs.name
  end
  eql? rhs
end

#eql?(rhs) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


96
97
98
99
100
101
102
103
104
# File 'lib/clasp/arguments.rb', line 96

def eql?(rhs)

  return false if rhs.nil?

  # check name and aliases
  return true if @name == rhs
  return argument_alias.aliases.include? rhs if argument_alias
  false
end

#hashObject

:nodoc:



118
119
120
121
# File 'lib/clasp/arguments.rb', line 118

def hash

  @arg.hash
end

#to_sObject

:nodoc:



90
91
92
93
# File 'lib/clasp/arguments.rb', line 90

def to_s

  @name
end