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.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.
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.
56
57
58
|
# File 'lib/inch/code_object/proxy/base.rb', line 56
def aliased_object
object_lookup.find( self[:aliased_object_fullname] )
end
|
#api_tag? ⇒ Boolean
Returns true
if the object has an @api tag.
61
62
63
|
# File 'lib/inch/code_object/proxy/base.rb', line 61
def api_tag?
self[:api_tag?]
end
|
#children ⇒ Array
Returns the children of the current object.
66
67
68
69
70
|
# File 'lib/inch/code_object/proxy/base.rb', line 66
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.
73
74
75
|
# File 'lib/inch/code_object/proxy/base.rb', line 73
def constant?
self[:constant?]
end
|
#core? ⇒ Boolean
77
78
79
|
# File 'lib/inch/code_object/proxy/base.rb', line 77
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?”
93
94
95
|
# File 'lib/inch/code_object/proxy/base.rb', line 93
def depth
self[:depth]
end
|
#docstring ⇒ Docstring
98
99
100
|
# File 'lib/inch/code_object/proxy/base.rb', line 98
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
108
109
110
111
112
|
# File 'lib/inch/code_object/proxy/base.rb', line 108
def filename
files.first
end
|
#files ⇒ Object
102
103
104
|
# File 'lib/inch/code_object/proxy/base.rb', line 102
def files
self[:files]
end
|
#fullname ⇒ String
Returns the fully qualified name of an object, e.g. “Inch::CodeObject::Provider::YARD::Docstring”.
122
123
124
|
# File 'lib/inch/code_object/proxy/base.rb', line 122
def fullname
self[:fullname]
end
|
#has_alias? ⇒ Boolean
126
127
128
|
# File 'lib/inch/code_object/proxy/base.rb', line 126
def has_alias?
!self[:aliases_fullnames].empty?
end
|
#has_children? ⇒ Boolean
130
131
132
|
# File 'lib/inch/code_object/proxy/base.rb', line 130
def has_children?
self[:has_children?]
end
|
#has_code_example? ⇒ Boolean
134
135
136
|
# File 'lib/inch/code_object/proxy/base.rb', line 134
def has_code_example?
self[:has_code_example?]
end
|
#has_doc? ⇒ Boolean
138
139
140
|
# File 'lib/inch/code_object/proxy/base.rb', line 138
def has_doc?
self[:has_doc?]
end
|
#has_multiple_code_examples? ⇒ Boolean
142
143
144
|
# File 'lib/inch/code_object/proxy/base.rb', line 142
def has_multiple_code_examples?
self[:has_multiple_code_examples?]
end
|
146
147
148
|
# File 'lib/inch/code_object/proxy/base.rb', line 146
def has_unconsidered_tags?
self[:has_unconsidered_tags?]
end
|
#in_root? ⇒ Boolean
150
151
152
|
# File 'lib/inch/code_object/proxy/base.rb', line 150
def in_root?
self[:in_root?]
end
|
#inspect ⇒ Object
235
236
237
|
# File 'lib/inch/code_object/proxy/base.rb', line 235
def inspect
"#<#{self.class.to_s}: #{fullname}>"
end
|
#marshal_dump ⇒ Object
Used to persist the code object
226
227
228
|
# File 'lib/inch/code_object/proxy/base.rb', line 226
def marshal_dump
@attributes
end
|
#marshal_load(attributes) ⇒ Object
Used to load a persisted code object
231
232
233
|
# File 'lib/inch/code_object/proxy/base.rb', line 231
def marshal_load(attributes)
@attributes = attributes
end
|
#method? ⇒ Boolean
Returns true
if the object represents a method.
155
156
157
|
# File 'lib/inch/code_object/proxy/base.rb', line 155
def method?
self[:method?]
end
|
#name ⇒ String
Returns the name of an object, e.g. “Docstring”.
116
117
118
|
# File 'lib/inch/code_object/proxy/base.rb', line 116
def name
self[:name]
end
|
#namespace? ⇒ Boolean
Returns true
if the object represents a namespace.
160
161
162
|
# File 'lib/inch/code_object/proxy/base.rb', line 160
def namespace?
self[:namespace?]
end
|
#nodoc? ⇒ Boolean
Returns true
if the object was tagged not to be documented.
169
170
171
|
# File 'lib/inch/code_object/proxy/base.rb', line 169
def nodoc?
self[:nodoc?]
end
|
#original_docstring ⇒ Object
164
165
166
|
# File 'lib/inch/code_object/proxy/base.rb', line 164
def original_docstring
self[:original_docstring]
end
|
Returns the parent of the current object or nil
.
174
175
176
|
# File 'lib/inch/code_object/proxy/base.rb', line 174
def parent
object_lookup.find( self[:parent_fullname] )
end
|
#private? ⇒ Boolean
178
179
180
|
# File 'lib/inch/code_object/proxy/base.rb', line 178
def private?
self[:private?]
end
|
#protected? ⇒ Boolean
195
196
197
|
# File 'lib/inch/code_object/proxy/base.rb', line 195
def protected?
self[:protected?]
end
|
#public? ⇒ Boolean
199
200
201
|
# File 'lib/inch/code_object/proxy/base.rb', line 199
def public?
self[:public?]
end
|
#source ⇒ Object
203
204
205
|
# File 'lib/inch/code_object/proxy/base.rb', line 203
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.
191
192
193
|
# File 'lib/inch/code_object/proxy/base.rb', line 191
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.
184
185
186
|
# File 'lib/inch/code_object/proxy/base.rb', line 184
def tagged_as_private?
self[:tagged_as_private?]
end
|
#type ⇒ Object
207
208
209
|
# File 'lib/inch/code_object/proxy/base.rb', line 207
def type
self.class.to_s.gsub(/Object$/, '')
end
|
#unconsidered_tag_count ⇒ Fixnum
Returns the amount of tags not considered for this object.
217
218
219
|
# File 'lib/inch/code_object/proxy/base.rb', line 217
def unconsidered_tag_count
self[:unconsidered_tag_count]
end
|
#undocumented? ⇒ Boolean
Returns true
if the object has no documentation at all.
212
213
214
|
# File 'lib/inch/code_object/proxy/base.rb', line 212
def undocumented?
self[:undocumented?]
end
|
#visibility ⇒ Object
221
222
223
|
# File 'lib/inch/code_object/proxy/base.rb', line 221
def visibility
self[:visibility]
end
|