Class: AutoTypeDoc::Argument

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, kind:, position:) ⇒ Argument

Returns a new instance of Argument.



5
6
7
8
9
10
# File 'lib/auto_type_doc/argument.rb', line 5

def initialize(name:, kind:, position:)
  @name = name.to_s
  @kind = kind.to_s
  @types = Hash.new(0)
  @position = position
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



3
4
5
# File 'lib/auto_type_doc/argument.rb', line 3

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/auto_type_doc/argument.rb', line 3

def name
  @name
end

#positionObject (readonly)

Returns the value of attribute position.



3
4
5
# File 'lib/auto_type_doc/argument.rb', line 3

def position
  @position
end

#typesObject (readonly)

Returns the value of attribute types.



3
4
5
# File 'lib/auto_type_doc/argument.rb', line 3

def types
  @types
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
# File 'lib/auto_type_doc/argument.rb', line 17

def ==(other)
  name == other.name
end

#add_type(type) ⇒ Object



12
13
14
15
# File 'lib/auto_type_doc/argument.rb', line 12

def add_type(type)
  type = type.to_s
  types[type] += 1
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/auto_type_doc/argument.rb', line 21

def eql?(other)
  self == other
end

#hashObject



25
26
27
# File 'lib/auto_type_doc/argument.rb', line 25

def hash
  name.hash
end

#to_hObject



29
30
31
32
33
34
35
36
# File 'lib/auto_type_doc/argument.rb', line 29

def to_h
  {
    name: name,
    types: types,
    kind: kind,
    position: position
  }
end