Class: PDoc::Models::Argument

Inherits:
Base
  • Object
show all
Defined in:
lib/pdoc/models/argument.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#description, #file, #line_number, #parent, #type

Instance Method Summary collapse

Methods inherited from Base

#ancestor_of?, #deprecated?, #descendant_of?, #doc_href, #full_name, #initialize, #inspect, instantiate, #normalized_name, #register_on, #short_description, #to_json, #url

Constructor Details

This class inherits a constructor from PDoc::Models::Base

Instance Attribute Details

#default_valueObject (readonly)

Returns the value of attribute default_value.



5
6
7
# File 'lib/pdoc/models/argument.rb', line 5

def default_value
  @default_value
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/pdoc/models/argument.rb', line 4

def name
  @name
end

Instance Method Details

#attach_to_parent(parent) ⇒ Object



7
8
9
# File 'lib/pdoc/models/argument.rb', line 7

def attach_to_parent(parent)
  parent.arguments << self
end

#idObject

returns the argument’s id in the form method_id:argument_name. So, for example: document.querySelectorAll:cssSelector



14
15
16
# File 'lib/pdoc/models/argument.rb', line 14

def id
  @id ||= "#{parent.id}:#{name}"
end

#optional?Boolean



18
19
20
# File 'lib/pdoc/models/argument.rb', line 18

def optional?
  !!@optional
end

#to_hashObject



26
27
28
29
30
31
32
33
34
# File 'lib/pdoc/models/argument.rb', line 26

def to_hash
  {
    :name => name,
    :description => description,
    :default_value => default_value,
    :optional => optional?,
    :types => types
  }
end

#typesObject



22
23
24
# File 'lib/pdoc/models/argument.rb', line 22

def types
  @types ||= []
end