Class: CLASP::Arguments::Option

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, value, extras) ⇒ Option

:nodoc:



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/clasp/arguments.rb', line 125

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

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

Instance Attribute Details

#argument_aliasObject (readonly)

Returns the value of attribute argument_alias.



140
141
142
# File 'lib/clasp/arguments.rb', line 140

def argument_alias
  @argument_alias
end

#extrasObject (readonly)

Returns the value of attribute extras.



145
146
147
# File 'lib/clasp/arguments.rb', line 145

def extras
  @extras
end

#given_hyphensObject (readonly)

Returns the value of attribute given_hyphens.



141
142
143
# File 'lib/clasp/arguments.rb', line 141

def given_hyphens
  @given_hyphens
end

#given_indexObject (readonly)

Returns the value of attribute given_index.



138
139
140
# File 'lib/clasp/arguments.rb', line 138

def given_index
  @given_index
end

#given_labelObject (readonly)

Returns the value of attribute given_label.



142
143
144
# File 'lib/clasp/arguments.rb', line 142

def given_label
  @given_label
end

#given_nameObject (readonly)

Returns the value of attribute given_name.



139
140
141
# File 'lib/clasp/arguments.rb', line 139

def given_name
  @given_name
end

#nameObject (readonly)

Returns the value of attribute name.



143
144
145
# File 'lib/clasp/arguments.rb', line 143

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



144
145
146
# File 'lib/clasp/arguments.rb', line 144

def value
  @value
end

Instance Method Details

#==(rhs) ⇒ Object

:nodoc:



159
160
161
162
163
164
165
166
167
# File 'lib/clasp/arguments.rb', line 159

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)


148
149
150
151
152
153
154
155
156
# File 'lib/clasp/arguments.rb', line 148

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:



170
171
172
173
# File 'lib/clasp/arguments.rb', line 170

def hash

  @arg.hash
end

#to_sObject

:nodoc:



176
177
178
179
# File 'lib/clasp/arguments.rb', line 176

def to_s

  "#{name}=#{value}"
end