Class: CLASP::Arguments::Flag

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) ⇒ Flag

:nodoc:



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

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.



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

def argument_alias
  @argument_alias
end

#extrasObject (readonly)

Returns the value of attribute extras.



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

def extras
  @extras
end

#given_hyphensObject (readonly)

Returns the value of attribute given_hyphens.



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

def given_hyphens
  @given_hyphens
end

#given_indexObject (readonly)

Returns the value of attribute given_index.



79
80
81
# File 'lib/clasp/arguments.rb', line 79

def given_index
  @given_index
end

#given_labelObject (readonly)

Returns the value of attribute given_label.



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

def given_label
  @given_label
end

#given_nameObject (readonly)

Returns the value of attribute given_name.



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

def given_name
  @given_name
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#==(rhs) ⇒ Object

:nodoc:



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

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)


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

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:



116
117
118
119
# File 'lib/clasp/arguments.rb', line 116

def hash

  @arg.hash
end

#to_sObject

:nodoc:



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

def to_s

  @name
end