Class: Inch::Language::Elixir::Provider::Reader::Object::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/inch/language/elixir/provider/reader/object/base.rb

Overview

This class is abstract.

Direct Known Subclasses

FunctionObject, ModuleObject, TypeObject

Constant Summary collapse

HIDDEN_TYPES =
%w(defcallback defmacro exception impl)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Base

Returns a new instance of Base

Parameters:

  • hash (Hash)

    hash returned via JSON interface



13
14
15
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 13

def initialize(hash)
  @hash = hash
end

Instance Attribute Details

#children_fullnamesObject



36
37
38
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 36

def children_fullnames
  @children_fullnames ||= []
end

Instance Method Details

#aliased_object_fullnameObject



52
53
54
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 52

def aliased_object_fullname
  nil
end

#aliases_fullnamesObject



56
57
58
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 56

def aliases_fullnames
  nil
end

#api_tag?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 48

def api_tag?
  nil
end

#attributesObject



60
61
62
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 60

def attributes
  []
end

#bang_name?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 64

def bang_name?
  false
end

#constant?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 68

def constant?
  false # raise NotImplementedError
end

#constructor?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 72

def constructor?
  false
end

#depthObject



76
77
78
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 76

def depth
  fullname.split('.').size
end

#docstringDocstring

Returns:



81
82
83
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 81

def docstring
  @docstring ||= Docstring.new(original_docstring)
end

#filenameObject



31
32
33
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 31

def filename
  location[0]
end

#filesObject



25
26
27
28
29
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 25

def files
  return [] if location.empty?
  file, line_no = location[0], location[1]
  [Inch::Utils::CodeLocation.new('', file, line_no)]
end

#fullnameObject



21
22
23
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 21

def fullname
  fail NotImplementedError
end

#getter?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 85

def getter?
  name =~ /^get_/ # raise NotImplementedError
end

#has_children?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 89

def has_children?
  !children_fullnames.empty?
end

#has_code_example?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 93

def has_code_example?
  docstring.code_examples.size > 0
end

#has_doc?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 97

def has_doc?
  !undocumented?
end

#has_multiple_code_examples?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 101

def has_multiple_code_examples?
  docstring.code_examples.size > 1
end

#has_unconsidered_tags?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 105

def has_unconsidered_tags?
  false # raise NotImplementedError
end

#in_root?Boolean

Returns:

  • (Boolean)


175
176
177
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 175

def in_root?
  depth == 1
end

#method?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 109

def method?
  false
end

#nameObject



17
18
19
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 17

def name
  @hash['name']
end

#namespace?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 119

def namespace?
  false
end

#nodoc?Boolean

Returns:

  • (Boolean)


114
115
116
117
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 114

def nodoc?
  @hash['doc'] == false ||
    HIDDEN_TYPES.include?(@hash['type'])
end

#original_docstringObject



123
124
125
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 123

def original_docstring
  @hash['doc']
end

#overridden?Boolean

Returns:

  • (Boolean)


127
128
129
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 127

def overridden?
  false # raise NotImplementedError
end

#overridden_method_fullnameObject



131
132
133
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 131

def overridden_method_fullname
  nil # raise NotImplementedError
end

#parametersObject



135
136
137
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 135

def parameters
  []
end

#parent_fullnameObject



40
41
42
43
44
45
46
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 40

def parent_fullname
  if depth == 1
    nil
  else
    fullname.split('.')[0...-1].join('.')
  end
end

#private?Boolean

Returns:

  • (Boolean)


139
140
141
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 139

def private?
  false
end

#protected?Boolean

Returns:

  • (Boolean)


151
152
153
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 151

def protected?
  false
end

#public?Boolean

Returns:

  • (Boolean)


155
156
157
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 155

def public?
  true
end

#questioning_name?Boolean

Returns:

  • (Boolean)


159
160
161
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 159

def questioning_name?
  fullname =~ /\?$/
end

#return_described?Boolean

Returns:

  • (Boolean)


163
164
165
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 163

def return_described?
  false # raise NotImplementedError
end

#return_mentioned?Boolean

Returns:

  • (Boolean)


167
168
169
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 167

def return_mentioned?
  false # raise NotImplementedError
end

#return_typed?Boolean

Returns:

  • (Boolean)


171
172
173
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 171

def return_typed?
  false # raise NotImplementedError
end

#setter?Boolean

Returns:

  • (Boolean)


179
180
181
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 179

def setter?
  name =~ /^set_/ # raise NotImplementedError
end

#sourceObject



183
184
185
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 183

def source
  nil
end

#tagged_as_internal_api?Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 143

def tagged_as_internal_api?
  false
end

#tagged_as_private?Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 147

def tagged_as_private?
  nodoc?
end

#unconsidered_tag_countObject



187
188
189
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 187

def unconsidered_tag_count
  0
end

#undocumented?Boolean

Returns:

  • (Boolean)


191
192
193
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 191

def undocumented?
  original_docstring.nil? || original_docstring.to_s.strip.empty?
end

#visibilityObject



195
196
197
# File 'lib/inch/language/elixir/provider/reader/object/base.rb', line 195

def visibility
  :public
end