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?”
79
80
81
|
# File 'lib/inch/code_object/proxy/base.rb', line 79
def depth
self[:depth]
end
|
#docstring ⇒ Docstring
84
85
86
|
# File 'lib/inch/code_object/proxy/base.rb', line 84
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
94
95
96
97
98
|
# File 'lib/inch/code_object/proxy/base.rb', line 94
def filename
files.first
end
|
#files ⇒ Object
88
89
90
|
# File 'lib/inch/code_object/proxy/base.rb', line 88
def files
self[:files]
end
|
#fullname ⇒ String
Returns 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
112
113
114
|
# File 'lib/inch/code_object/proxy/base.rb', line 112
def has_alias?
self[:has_alias?]
end
|
#has_children? ⇒ 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
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
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
128
129
130
|
# File 'lib/inch/code_object/proxy/base.rb', line 128
def has_multiple_code_examples?
self[:has_multiple_code_examples?]
end
|
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
136
137
138
|
# File 'lib/inch/code_object/proxy/base.rb', line 136
def in_root?
self[:in_root?]
end
|
#inspect ⇒ Object
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.
141
142
143
|
# File 'lib/inch/code_object/proxy/base.rb', line 141
def method?
self[:method?]
end
|
#name ⇒ String
Returns 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.
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.
151
152
153
|
# File 'lib/inch/code_object/proxy/base.rb', line 151
def nodoc?
self[:nodoc?]
end
|
#parent ⇒ Array?
Returns 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
160
161
162
|
# File 'lib/inch/code_object/proxy/base.rb', line 160
def private?
self[:private?]
end
|
#protected? ⇒ Boolean
177
178
179
|
# File 'lib/inch/code_object/proxy/base.rb', line 177
def protected?
self[:protected?]
end
|
#public? ⇒ Boolean
181
182
183
|
# File 'lib/inch/code_object/proxy/base.rb', line 181
def public?
self[:public?]
end
|
#source ⇒ Object
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.
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.
166
167
168
|
# File 'lib/inch/code_object/proxy/base.rb', line 166
def tagged_as_private?
self[:tagged_as_private?]
end
|
#unconsidered_tag_count ⇒ Fixnum
Returns 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.
190
191
192
|
# File 'lib/inch/code_object/proxy/base.rb', line 190
def undocumented?
self[:undocumented?]
end
|
#visibility ⇒ Object
199
200
201
|
# File 'lib/inch/code_object/proxy/base.rb', line 199
def visibility
self[:visibility]
end
|