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
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
#grade ⇒ 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.
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
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.
47
48
49
|
# File 'lib/inch/code_object/proxy/base.rb', line 47
def api_tag?
self[:api_tag?]
end
|
#children ⇒ Array
Returns 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.
59
60
61
|
# File 'lib/inch/code_object/proxy/base.rb', line 59
def constant?
self[:constant?]
end
|
#core? ⇒ Boolean
63
64
65
|
# File 'lib/inch/code_object/proxy/base.rb', line 63
def core?
self[:api_tag?]
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?”
80
81
82
|
# File 'lib/inch/code_object/proxy/base.rb', line 80
def depth
self[:depth]
end
|
#docstring ⇒ Docstring
85
86
87
|
# File 'lib/inch/code_object/proxy/base.rb', line 85
def docstring
self[:docstring]
end
|
#evaluation ⇒ Evaluation::Base
35
36
37
|
# File 'lib/inch/code_object/proxy/base.rb', line 35
def evaluation
@evaluation ||= Evaluation::Proxy.for(self)
end
|
#filename ⇒ String
Returns the name of the file where the object is declared first
95
96
97
98
99
|
# File 'lib/inch/code_object/proxy/base.rb', line 95
def filename
files.first
end
|
#files ⇒ Object
89
90
91
|
# File 'lib/inch/code_object/proxy/base.rb', line 89
def files
self[:files]
end
|
#fullname ⇒ String
Returns the fully qualified name of an object, e.g. “Inch::CodeObject::Provider::YARD::Docstring”.
109
110
111
|
# File 'lib/inch/code_object/proxy/base.rb', line 109
def fullname
self[:fullname]
end
|
#has_alias? ⇒ Boolean
113
114
115
|
# File 'lib/inch/code_object/proxy/base.rb', line 113
def has_alias?
self[:has_alias?]
end
|
#has_children? ⇒ Boolean
117
118
119
|
# File 'lib/inch/code_object/proxy/base.rb', line 117
def has_children?
self[:has_children?]
end
|
#has_code_example? ⇒ Boolean
121
122
123
|
# File 'lib/inch/code_object/proxy/base.rb', line 121
def has_code_example?
self[:has_code_example?]
end
|
#has_doc? ⇒ Boolean
125
126
127
|
# File 'lib/inch/code_object/proxy/base.rb', line 125
def has_doc?
self[:has_doc?]
end
|
#has_multiple_code_examples? ⇒ Boolean
129
130
131
|
# File 'lib/inch/code_object/proxy/base.rb', line 129
def has_multiple_code_examples?
self[:has_multiple_code_examples?]
end
|
133
134
135
|
# File 'lib/inch/code_object/proxy/base.rb', line 133
def has_unconsidered_tags?
self[:has_unconsidered_tags?]
end
|
#in_root? ⇒ Boolean
137
138
139
|
# File 'lib/inch/code_object/proxy/base.rb', line 137
def in_root?
self[:in_root?]
end
|
#inspect ⇒ Object
201
202
203
|
# File 'lib/inch/code_object/proxy/base.rb', line 201
def inspect
"#<#{self.class.to_s}: #{fullname}>"
end
|
#method? ⇒ Boolean
Returns true
if the object represents a method.
142
143
144
|
# File 'lib/inch/code_object/proxy/base.rb', line 142
def method?
self[:method?]
end
|
#name ⇒ String
Returns the name of an object, e.g. “Docstring”.
103
104
105
|
# File 'lib/inch/code_object/proxy/base.rb', line 103
def name
self[:name]
end
|
#namespace? ⇒ Boolean
Returns true
if the object represents a namespace.
147
148
149
|
# File 'lib/inch/code_object/proxy/base.rb', line 147
def namespace?
self[:namespace?]
end
|
#nodoc? ⇒ Boolean
Returns true
if the object was tagged not to be documented.
152
153
154
|
# File 'lib/inch/code_object/proxy/base.rb', line 152
def nodoc?
self[:nodoc?]
end
|
#parent ⇒ Array?
Returns the parent of the current object or nil
.
157
158
159
|
# File 'lib/inch/code_object/proxy/base.rb', line 157
def parent
object_lookup.find( self[:parent_fullname] )
end
|
#private? ⇒ Boolean
161
162
163
|
# File 'lib/inch/code_object/proxy/base.rb', line 161
def private?
self[:private?]
end
|
#private_api_tag? ⇒ Boolean
171
172
173
|
# File 'lib/inch/code_object/proxy/base.rb', line 171
def private_api_tag?
self[:private_api_tag?]
end
|
#private_tag? ⇒ Boolean
Returns true
if the object or its parent is tagged as @private.
167
168
169
|
# File 'lib/inch/code_object/proxy/base.rb', line 167
def private_tag?
self[:private_tag?]
end
|
#protected? ⇒ Boolean
175
176
177
|
# File 'lib/inch/code_object/proxy/base.rb', line 175
def protected?
self[:protected?]
end
|
#public? ⇒ Boolean
179
180
181
|
# File 'lib/inch/code_object/proxy/base.rb', line 179
def public?
self[:public?]
end
|
#source ⇒ Object
183
184
185
|
# File 'lib/inch/code_object/proxy/base.rb', line 183
def source
self[:source]
end
|
#unconsidered_tag_count ⇒ Fixnum
Returns the amount of tags not considered for this object.
193
194
195
|
# File 'lib/inch/code_object/proxy/base.rb', line 193
def unconsidered_tag_count
self[:unconsidered_tag_count]
end
|
#undocumented? ⇒ Boolean
Returns true
if the object has no documentation at all.
188
189
190
|
# File 'lib/inch/code_object/proxy/base.rb', line 188
def undocumented?
self[:undocumented?]
end
|
#visibility ⇒ Object
197
198
199
|
# File 'lib/inch/code_object/proxy/base.rb', line 197
def visibility
self[:visibility]
end
|