Class: Inch::Language::Elixir::CodeObject::Base

Inherits:
CodeObject::Proxy show all
Defined in:
lib/inch/language/elixir/code_object/base.rb

Direct Known Subclasses

FunctionObject, ModuleObject, TypeObject

Instance Attribute Summary

Attributes inherited from CodeObject::Proxy

#object_lookup

Instance Method Summary collapse

Methods inherited from CodeObject::Proxy

#[], for, #initialize, #inspect, #marshal_dump, #marshal_load

Constructor Details

This class inherits a constructor from Inch::CodeObject::Proxy

Instance Method Details

#alias?Boolean

Returns if the current object is an alias for something else.

Returns:

  • (Boolean)

    if the current object is an alias for something else



19
20
21
# File 'lib/inch/language/elixir/code_object/base.rb', line 19

def alias?
  !aliased_object.nil?
end

#aliased_objectCodeObject::Proxy

Returns the object the current object is an alias of.

Returns:



25
26
27
# File 'lib/inch/language/elixir/code_object/base.rb', line 25

def aliased_object
  object_lookup.find(self[:aliased_object_fullname])
end

#api_tag?Boolean

Returns true if the object has an @api tag.

Returns:

  • (Boolean)

    true if the object has an @api tag



30
31
32
# File 'lib/inch/language/elixir/code_object/base.rb', line 30

def api_tag?
  self[:api_tag?]
end

#childrenArray

Returns the children of the current object.

Returns:

  • (Array)

    the children of the current object



35
36
37
38
39
# File 'lib/inch/language/elixir/code_object/base.rb', line 35

def children
  @children ||= self[:children_fullnames].map do |fullname|
    object_lookup.find(fullname)
  end
end

#constant?Boolean

Returns true if the object represents a constant.

Returns:

  • (Boolean)

    true if the object represents a constant



42
43
44
# File 'lib/inch/language/elixir/code_object/base.rb', line 42

def constant?
  self[:constant?]
end

#core?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/inch/language/elixir/code_object/base.rb', line 46

def core?
  self[:core?]
end

#depthFixnum

Note:

top-level counts, that’s why Foo has depth 1!

The depth of the following is 4:

Foo::Bar::Baz#initialize
 ^    ^    ^      ^
 1 << 2 << 3  <<  4

depth answers the question “how many layers of code objects are above this one?”

Returns:

  • (Fixnum)

    the depth of the object in terms of namespace



62
63
64
# File 'lib/inch/language/elixir/code_object/base.rb', line 62

def depth
  self[:depth]
end

#docstringDocstring

Returns:

  • (Docstring)


67
68
69
# File 'lib/inch/language/elixir/code_object/base.rb', line 67

def docstring
  self[:docstring]
end

#filenameString

Returns the name of the file where the object is declared first

Returns:

  • (String)

    a filename



77
78
79
80
81
# File 'lib/inch/language/elixir/code_object/base.rb', line 77

def filename
  # just checking the first file (which is the file where an object
  # is first declared)
  files.first
end

#filesObject



71
72
73
# File 'lib/inch/language/elixir/code_object/base.rb', line 71

def files
  self[:files]
end

#fullnameString

Returns the fully qualified name of an object, e.g. “Inch::CodeObject::Provider::YARD::Docstring”.

Returns:

  • (String)

    the fully qualified name of an object, e.g. “Inch::CodeObject::Provider::YARD::Docstring”



91
92
93
# File 'lib/inch/language/elixir/code_object/base.rb', line 91

def fullname
  self[:fullname]
end

#has_alias?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/inch/language/elixir/code_object/base.rb', line 95

def has_alias?
  !self[:aliases_fullnames].empty?
end

#has_children?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/inch/language/elixir/code_object/base.rb', line 99

def has_children?
  self[:has_children?]
end

#has_code_example?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/inch/language/elixir/code_object/base.rb', line 103

def has_code_example?
  self[:has_code_example?]
end

#has_doc?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/inch/language/elixir/code_object/base.rb', line 107

def has_doc?
  self[:has_doc?]
end

#has_multiple_code_examples?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/inch/language/elixir/code_object/base.rb', line 111

def has_multiple_code_examples?
  self[:has_multiple_code_examples?]
end

#has_unconsidered_tags?Boolean

Returns:

  • (Boolean)


115
116
117
# File 'lib/inch/language/elixir/code_object/base.rb', line 115

def has_unconsidered_tags?
  self[:has_unconsidered_tags?]
end

#in_root?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/inch/language/elixir/code_object/base.rb', line 119

def in_root?
  self[:in_root?]
end

#languageObject



13
14
15
# File 'lib/inch/language/elixir/code_object/base.rb', line 13

def language
  :elixir
end

#method?Boolean

Returns true if the object represents a method.

Returns:

  • (Boolean)

    true if the object represents a method



124
125
126
# File 'lib/inch/language/elixir/code_object/base.rb', line 124

def method?
  self[:method?]
end

#nameString

Returns the name of an object, e.g. “Docstring”.

Returns:

  • (String)

    the name of an object, e.g. “Docstring”



85
86
87
# File 'lib/inch/language/elixir/code_object/base.rb', line 85

def name
  self[:name]
end

#namespace?Boolean

Returns true if the object represents a namespace.

Returns:

  • (Boolean)

    true if the object represents a namespace



129
130
131
# File 'lib/inch/language/elixir/code_object/base.rb', line 129

def namespace?
  self[:namespace?]
end

#nodoc?Boolean

Returns true if the object was tagged not to be documented.

Returns:

  • (Boolean)

    true if the object was tagged not to be documented



139
140
141
# File 'lib/inch/language/elixir/code_object/base.rb', line 139

def nodoc?
  self[:nodoc?]
end

#original_docstringObject



133
134
135
# File 'lib/inch/language/elixir/code_object/base.rb', line 133

def original_docstring
  self[:original_docstring]
end

#parentCodeObject::Proxy?

Returns the parent of the current object or nil.

Returns:



145
146
147
# File 'lib/inch/language/elixir/code_object/base.rb', line 145

def parent
  object_lookup.find(self[:parent_fullname])
end

#private?Boolean

Returns:

  • (Boolean)


149
150
151
# File 'lib/inch/language/elixir/code_object/base.rb', line 149

def private?
  self[:private?]
end

#protected?Boolean

Returns:

  • (Boolean)


166
167
168
# File 'lib/inch/language/elixir/code_object/base.rb', line 166

def protected?
  self[:protected?]
end

#public?Boolean

Returns:

  • (Boolean)


170
171
172
# File 'lib/inch/language/elixir/code_object/base.rb', line 170

def public?
  self[:public?]
end

#sourceObject



174
175
176
# File 'lib/inch/language/elixir/code_object/base.rb', line 174

def source
  self[:source]
end

#tagged_as_internal_api?Boolean

Returns true if the object or its parent is tagged as part of an internal api.

Returns:

  • (Boolean)

    true if the object or its parent is tagged as part of an internal api



162
163
164
# File 'lib/inch/language/elixir/code_object/base.rb', line 162

def tagged_as_internal_api?
  self[:tagged_as_internal_api?]
end

#tagged_as_private?Boolean

Returns true if the object or its parent is tagged as @private.

Returns:

  • (Boolean)

    true if the object or its parent is tagged as @private



155
156
157
# File 'lib/inch/language/elixir/code_object/base.rb', line 155

def tagged_as_private?
  self[:tagged_as_private?]
end

#typeObject



178
179
180
# File 'lib/inch/language/elixir/code_object/base.rb', line 178

def type
  self.class.to_s.gsub(/Object$/, '')
end

#unconsidered_tag_countFixnum

Returns the amount of tags not considered for this object.

Returns:

  • (Fixnum)

    the amount of tags not considered for this object



188
189
190
# File 'lib/inch/language/elixir/code_object/base.rb', line 188

def unconsidered_tag_count
  self[:unconsidered_tag_count]
end

#undocumented?Boolean

Returns true if the object has no documentation at all.

Returns:

  • (Boolean)

    true if the object has no documentation at all



183
184
185
# File 'lib/inch/language/elixir/code_object/base.rb', line 183

def undocumented?
  self[:undocumented?]
end

#visibilityObject



192
193
194
# File 'lib/inch/language/elixir/code_object/base.rb', line 192

def visibility
  self[:visibility]
end