Class: Inch::CodeObject::Proxy::Base
Abstract
- Inherits:
-
Object
- Object
- Inch::CodeObject::Proxy::Base
show all
- Extended by:
- Forwardable
- Defined in:
- lib/inch/code_object/proxy/base.rb
Overview
This is the base class for code object proxies. Code object proxies are via an attributes Hash and provide all methods necessary for the evaluation of its documentation.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
27
28
29
|
# File 'lib/inch/code_object/proxy/base.rb', line 27
def initialize(attributes = {})
@attributes = attributes
end
|
Instance Attribute Details
#grade ⇒ Symbol
44
45
46
47
48
|
# File 'lib/inch/code_object/proxy/base.rb', line 44
def grade
@grade ||= Evaluation.new_grade_lists.find do |range|
range.scores.include?(score)
end.grade
end
|
#object_lookup ⇒ #find
Returns an object that responds to #find to look up objects by their full name.
22
23
24
|
# File 'lib/inch/code_object/proxy/base.rb', line 22
def object_lookup
@object_lookup
end
|
Instance Method Details
#[](key) ⇒ Object
Returns the attribute for the given key
34
35
36
|
# File 'lib/inch/code_object/proxy/base.rb', line 34
def [](key)
@attributes[key]
end
|
#alias? ⇒ Boolean
Returns if the current object is an alias for something else.
51
52
53
|
# File 'lib/inch/code_object/proxy/base.rb', line 51
def alias?
!aliased_object.nil?
end
|
Returns the object the current object is an alias of.
57
58
59
|
# File 'lib/inch/code_object/proxy/base.rb', line 57
def aliased_object
object_lookup.find(self[:aliased_object_fullname])
end
|
#api_tag? ⇒ Boolean
Returns true
if the object has an @api tag.
62
63
64
|
# File 'lib/inch/code_object/proxy/base.rb', line 62
def api_tag?
self[:api_tag?]
end
|
#children ⇒ Array
Returns the children of the current object.
67
68
69
70
71
|
# File 'lib/inch/code_object/proxy/base.rb', line 67
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.
74
75
76
|
# File 'lib/inch/code_object/proxy/base.rb', line 74
def constant?
self[:constant?]
end
|
#core? ⇒ Boolean
78
79
80
|
# File 'lib/inch/code_object/proxy/base.rb', line 78
def core?
self[:core?]
end
|
#depth ⇒ Fixnum
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?”
94
95
96
|
# File 'lib/inch/code_object/proxy/base.rb', line 94
def depth
self[:depth]
end
|
#docstring ⇒ Docstring
99
100
101
|
# File 'lib/inch/code_object/proxy/base.rb', line 99
def docstring
self[:docstring]
end
|
#evaluation ⇒ Evaluation::Base
39
40
41
|
# File 'lib/inch/code_object/proxy/base.rb', line 39
def evaluation
@evaluation ||= Evaluation::Proxy.for(self)
end
|
#filename ⇒ String
Returns the name of the file where the object is declared first
109
110
111
112
113
|
# File 'lib/inch/code_object/proxy/base.rb', line 109
def filename
files.first
end
|
#files ⇒ Object
103
104
105
|
# File 'lib/inch/code_object/proxy/base.rb', line 103
def files
self[:files]
end
|
#fullname ⇒ String
Returns the fully qualified name of an object, e.g. “Inch::CodeObject::Provider::YARD::Docstring”.
123
124
125
|
# File 'lib/inch/code_object/proxy/base.rb', line 123
def fullname
self[:fullname]
end
|
#has_alias? ⇒ Boolean
127
128
129
|
# File 'lib/inch/code_object/proxy/base.rb', line 127
def has_alias?
!self[:aliases_fullnames].empty?
end
|
#has_children? ⇒ Boolean
131
132
133
|
# File 'lib/inch/code_object/proxy/base.rb', line 131
def has_children?
self[:has_children?]
end
|
#has_code_example? ⇒ Boolean
135
136
137
|
# File 'lib/inch/code_object/proxy/base.rb', line 135
def has_code_example?
self[:has_code_example?]
end
|
#has_doc? ⇒ Boolean
139
140
141
|
# File 'lib/inch/code_object/proxy/base.rb', line 139
def has_doc?
self[:has_doc?]
end
|
#has_multiple_code_examples? ⇒ Boolean
143
144
145
|
# File 'lib/inch/code_object/proxy/base.rb', line 143
def has_multiple_code_examples?
self[:has_multiple_code_examples?]
end
|
147
148
149
|
# File 'lib/inch/code_object/proxy/base.rb', line 147
def has_unconsidered_tags?
self[:has_unconsidered_tags?]
end
|
#in_root? ⇒ Boolean
151
152
153
|
# File 'lib/inch/code_object/proxy/base.rb', line 151
def in_root?
self[:in_root?]
end
|
#inspect ⇒ Object
237
238
239
|
# File 'lib/inch/code_object/proxy/base.rb', line 237
def inspect
"#<#{self.class}: #{fullname}>"
end
|
#marshal_dump ⇒ Object
Used to persist the code object
228
229
230
|
# File 'lib/inch/code_object/proxy/base.rb', line 228
def marshal_dump
@attributes
end
|
#marshal_load(attributes) ⇒ Object
Used to load a persisted code object
233
234
235
|
# File 'lib/inch/code_object/proxy/base.rb', line 233
def marshal_load(attributes)
@attributes = attributes
end
|
#method? ⇒ Boolean
Returns true
if the object represents a method.
156
157
158
|
# File 'lib/inch/code_object/proxy/base.rb', line 156
def method?
self[:method?]
end
|
#name ⇒ String
Returns the name of an object, e.g. “Docstring”.
117
118
119
|
# File 'lib/inch/code_object/proxy/base.rb', line 117
def name
self[:name]
end
|
#namespace? ⇒ Boolean
Returns true
if the object represents a namespace.
161
162
163
|
# File 'lib/inch/code_object/proxy/base.rb', line 161
def namespace?
self[:namespace?]
end
|
#nodoc? ⇒ Boolean
Returns true
if the object was tagged not to be documented.
170
171
172
|
# File 'lib/inch/code_object/proxy/base.rb', line 170
def nodoc?
self[:nodoc?]
end
|
#original_docstring ⇒ Object
165
166
167
|
# File 'lib/inch/code_object/proxy/base.rb', line 165
def original_docstring
self[:original_docstring]
end
|
Returns the parent of the current object or nil
.
176
177
178
|
# File 'lib/inch/code_object/proxy/base.rb', line 176
def parent
object_lookup.find(self[:parent_fullname])
end
|
#private? ⇒ Boolean
180
181
182
|
# File 'lib/inch/code_object/proxy/base.rb', line 180
def private?
self[:private?]
end
|
#protected? ⇒ Boolean
197
198
199
|
# File 'lib/inch/code_object/proxy/base.rb', line 197
def protected?
self[:protected?]
end
|
#public? ⇒ Boolean
201
202
203
|
# File 'lib/inch/code_object/proxy/base.rb', line 201
def public?
self[:public?]
end
|
#source ⇒ Object
205
206
207
|
# File 'lib/inch/code_object/proxy/base.rb', line 205
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.
193
194
195
|
# File 'lib/inch/code_object/proxy/base.rb', line 193
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.
186
187
188
|
# File 'lib/inch/code_object/proxy/base.rb', line 186
def tagged_as_private?
self[:tagged_as_private?]
end
|
#type ⇒ Object
209
210
211
|
# File 'lib/inch/code_object/proxy/base.rb', line 209
def type
self.class.to_s.gsub(/Object$/, "")
end
|
#unconsidered_tag_count ⇒ Fixnum
Returns the amount of tags not considered for this object.
219
220
221
|
# File 'lib/inch/code_object/proxy/base.rb', line 219
def unconsidered_tag_count
self[:unconsidered_tag_count]
end
|
#undocumented? ⇒ Boolean
Returns true
if the object has no documentation at all.
214
215
216
|
# File 'lib/inch/code_object/proxy/base.rb', line 214
def undocumented?
self[:undocumented?]
end
|
#visibility ⇒ Object
223
224
225
|
# File 'lib/inch/code_object/proxy/base.rb', line 223
def visibility
self[:visibility]
end
|