Class: Inch::CodeObject::Proxy::Base Abstract

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/inch/code_object/proxy/base.rb

Overview

This class is abstract.

Direct Known Subclasses

ConstantObject, MethodObject, NamespaceObject

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Base

Returns a new instance of Base.



23
24
25
# File 'lib/inch/code_object/proxy/base.rb', line 23

def initialize(attributes)
  @attributes = attributes
end

Instance Attribute Details

#gradeSymbol

Returns:

  • (Symbol)


40
41
42
43
44
# File 'lib/inch/code_object/proxy/base.rb', line 40

def grade
  @grade ||= Evaluation.new_grade_lists.detect { |range|
        range.scores.include?(score)
      }.grade
end

#object_lookup#find

Returns an object that responds to #find to look up objects by their full name.

Returns:

  • (#find)

    an object that responds to #find to look up objects by their full name



18
19
20
# File 'lib/inch/code_object/proxy/base.rb', line 18

def object_lookup
  @object_lookup
end

Instance Method Details

#[](key) ⇒ Object

Returns the attribute for the given key

Parameters:

  • key (Symbol)


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

def [](key)
  @attributes[key]
end

#api_tag?Boolean

Returns true if the object has an @api tag.

Returns:

  • (Boolean)

    true if the object has an @api tag



47
48
49
# File 'lib/inch/code_object/proxy/base.rb', line 47

def api_tag?
  self[:api_tag?]
end

#childrenArray

Returns the children of the current object.

Returns:

  • (Array)

    the children of the current object



52
53
54
55
56
# File 'lib/inch/code_object/proxy/base.rb', line 52

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



59
60
61
# File 'lib/inch/code_object/proxy/base.rb', line 59

def constant?
  self[:constant?]
end

#core?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/inch/code_object/proxy/base.rb', line 63

def core?
  self[:api_tag?]
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



79
80
81
# File 'lib/inch/code_object/proxy/base.rb', line 79

def depth
  self[:depth]
end

#docstringDocstring

Returns:

  • (Docstring)


84
85
86
# File 'lib/inch/code_object/proxy/base.rb', line 84

def docstring
  self[:docstring]
end

#evaluationEvaluation::Base

Returns:

  • (Evaluation::Base)


35
36
37
# File 'lib/inch/code_object/proxy/base.rb', line 35

def evaluation
  @evaluation ||= Evaluation::Proxy.for(self)
end

#filenameString

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

Returns:

  • (String)

    a filename



94
95
96
97
98
# File 'lib/inch/code_object/proxy/base.rb', line 94

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

#filesObject



88
89
90
# File 'lib/inch/code_object/proxy/base.rb', line 88

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”



108
109
110
# File 'lib/inch/code_object/proxy/base.rb', line 108

def fullname
  self[:fullname]
end

#has_alias?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/inch/code_object/proxy/base.rb', line 112

def has_alias?
  self[:has_alias?]
end

#has_children?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'lib/inch/code_object/proxy/base.rb', line 116

def has_children?
  self[:has_children?]
end

#has_code_example?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/inch/code_object/proxy/base.rb', line 120

def has_code_example?
  self[:has_code_example?]
end

#has_doc?Boolean

Returns:

  • (Boolean)


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

def has_doc?
  self[:has_doc?]
end

#has_multiple_code_examples?Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/inch/code_object/proxy/base.rb', line 128

def has_multiple_code_examples?
  self[:has_multiple_code_examples?]
end

#has_unconsidered_tags?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/inch/code_object/proxy/base.rb', line 132

def has_unconsidered_tags?
  self[:has_unconsidered_tags?]
end

#in_root?Boolean

Returns:

  • (Boolean)


136
137
138
# File 'lib/inch/code_object/proxy/base.rb', line 136

def in_root?
  self[:in_root?]
end

#inspectObject



203
204
205
# File 'lib/inch/code_object/proxy/base.rb', line 203

def inspect
  "#<#{self.class.to_s}: #{fullname}>"
end

#method?Boolean

Returns true if the object represents a method.

Returns:

  • (Boolean)

    true if the object represents a method



141
142
143
# File 'lib/inch/code_object/proxy/base.rb', line 141

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”



102
103
104
# File 'lib/inch/code_object/proxy/base.rb', line 102

def name
  self[:name]
end

#namespace?Boolean

Returns true if the object represents a namespace.

Returns:

  • (Boolean)

    true if the object represents a namespace



146
147
148
# File 'lib/inch/code_object/proxy/base.rb', line 146

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



151
152
153
# File 'lib/inch/code_object/proxy/base.rb', line 151

def nodoc?
  self[:nodoc?]
end

#parentArray?

Returns the parent of the current object or nil.

Returns:

  • (Array, nil)

    the parent of the current object or nil



156
157
158
# File 'lib/inch/code_object/proxy/base.rb', line 156

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

#private?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'lib/inch/code_object/proxy/base.rb', line 160

def private?
  self[:private?]
end

#protected?Boolean

Returns:

  • (Boolean)


177
178
179
# File 'lib/inch/code_object/proxy/base.rb', line 177

def protected?
  self[:protected?]
end

#public?Boolean

Returns:

  • (Boolean)


181
182
183
# File 'lib/inch/code_object/proxy/base.rb', line 181

def public?
  self[:public?]
end

#sourceObject



185
186
187
# File 'lib/inch/code_object/proxy/base.rb', line 185

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



173
174
175
# File 'lib/inch/code_object/proxy/base.rb', line 173

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



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

def tagged_as_private?
  self[:tagged_as_private?]
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



195
196
197
# File 'lib/inch/code_object/proxy/base.rb', line 195

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



190
191
192
# File 'lib/inch/code_object/proxy/base.rb', line 190

def undocumented?
  self[:undocumented?]
end

#visibilityObject



199
200
201
# File 'lib/inch/code_object/proxy/base.rb', line 199

def visibility
  self[:visibility]
end