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:



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

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.



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

def argument_alias
  @argument_alias
end

#extrasObject (readonly)

Returns the value of attribute extras.



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

def extras
  @extras
end

#given_hyphensObject (readonly)

Returns the value of attribute given_hyphens.



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

def given_hyphens
  @given_hyphens
end

#given_indexObject (readonly)

Returns the value of attribute given_index.



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

def given_index
  @given_index
end

#given_labelObject (readonly)

Returns the value of attribute given_label.



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

def given_label
  @given_label
end

#given_nameObject (readonly)

Returns the value of attribute given_name.



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

def given_name
  @given_name
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#==(rhs) ⇒ Object

:nodoc:



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

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)


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

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:



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

def hash

	@arg.hash
end

#to_sObject

:nodoc:



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

def to_s

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