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



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

def initialize(attributes)
  @attributes = attributes
end

Instance Attribute Details

#gradeSymbol



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



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



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

def api_tag?
  self[:api_tag?]
end

#childrenArray



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



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

#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?”



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

def depth
  self[:depth]
end

#docstringDocstring



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

def docstring
  self[:docstring]
end

#evaluationEvaluation::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



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



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

#has_unconsidered_tags?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



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



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

def method?
  self[:method?]
end

#nameString



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

def name
  self[:name]
end

#namespace?Boolean



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

def namespace?
  self[:namespace?]
end

#nodoc?Boolean



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

def nodoc?
  self[:nodoc?]
end

#parentArray?



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

#sourceObject



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

def source
  self[:source]
end

#tagged_as_internal_api?Boolean



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



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



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

def unconsidered_tag_count
  self[:unconsidered_tag_count]
end

#undocumented?Boolean



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