Class: Inch::Language::Nodejs::Provider::JSDoc::Object::Base Abstract

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

Overview

This class is abstract.

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



16
17
18
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 16

def initialize(hash)
  @hash = hash
end

Instance Attribute Details

#base_dirString

Returns the codebase's directory

Returns:

  • (String)

    the codebase's directory



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

def base_dir
  @base_dir
end

#children_fullnamesObject



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

def children_fullnames
  @children_fullnames ||= []
end

Instance Method Details

#aliased_object_fullnameObject



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

def aliased_object_fullname
  nil
end

#aliases_fullnamesObject



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

def aliases_fullnames
  nil
end

#api_tag?Boolean

Returns:

  • (Boolean)


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

def api_tag?
  nil
end

#attributesObject



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

def attributes
  []
end

#bang_name?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 80

def bang_name?
  false
end

#constant?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 84

def constant?
  false # raise NotImplementedError
end

#constructor?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 88

def constructor?
  false
end

#depthObject



92
93
94
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 92

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

#docstringDocstring

Returns:



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

def docstring
  @docstring ||= Docstring.new(@hash['comment'])
end

#filenameObject



47
48
49
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 47

def filename
  files.first.filename unless files.empty?
end

#filesArray<CodeLocation>

Returns all files declaring the object in the form of an Array of Arrays containing the location of their declaration.

Returns:

  • (Array<CodeLocation>)


39
40
41
42
43
44
45
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 39

def files
  return [] unless meta?
  filename = meta['path'] + '/' + meta['filename']
  [
    Inch::Utils::CodeLocation.new('', filename, meta['lineno'])
  ]
end

#fullnameObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 24

def fullname
  #fail NotImplementedError
  base = "#{@hash['longname']}"
  if meta?
    base << " @ #{meta['path']}/" \
            "#{meta['filename']}:" \
            "#{meta['lineno']}"
  end
  base
end

#getter?Boolean

Returns:

  • (Boolean)


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

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

#has_children?Boolean

Returns:

  • (Boolean)


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

def has_children?
  !children_fullnames.empty?
end

#has_code_example?Boolean

Returns:

  • (Boolean)


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

def has_code_example?
  false # raise NotImplementedError
end

#has_doc?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 113

def has_doc?
  !undocumented?
end

#has_multiple_code_examples?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 117

def has_multiple_code_examples?
  false # raise NotImplementedError
end

#has_unconsidered_tags?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 121

def has_unconsidered_tags?
  false # raise NotImplementedError
end

#in_root?Boolean

Returns:

  • (Boolean)


196
197
198
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 196

def in_root?
  depth == 1
end

#method?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 125

def method?
  false
end

#nameObject



20
21
22
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 20

def name
  @hash['name']
end

#namespace?Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 133

def namespace?
  false
end

#nodoc?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 129

def nodoc?
  @hash['comment'] == false
end

#original_docstringObject



137
138
139
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 137

def original_docstring
  @hash['comment']
end

#overridden?Boolean

Returns:

  • (Boolean)


141
142
143
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 141

def overridden?
  false # raise NotImplementedError
end

#overridden_method_fullnameObject



145
146
147
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 145

def overridden_method_fullname
  nil # raise NotImplementedError
end

#parametersObject



149
150
151
152
153
154
155
156
157
158
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 149

def parameters
  if meta? && meta['code']
    names = meta['code']['paramnames'] || []
    names.map do |name|
      FunctionParameterObject.new(self, name)
    end
  else
    []
  end
end

#parent_fullnameObject



56
57
58
59
60
61
62
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 56

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

#private?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 160

def private?
  false
end

#protected?Boolean

Returns:

  • (Boolean)


172
173
174
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 172

def protected?
  false
end

#public?Boolean

Returns:

  • (Boolean)


176
177
178
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 176

def public?
  true
end

#questioning_name?Boolean

Returns:

  • (Boolean)


180
181
182
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 180

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

#return_described?Boolean

Returns:

  • (Boolean)


184
185
186
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 184

def return_described?
  false # raise NotImplementedError
end

#return_mentioned?Boolean

Returns:

  • (Boolean)


188
189
190
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 188

def return_mentioned?
  false # raise NotImplementedError
end

#return_typed?Boolean

Returns:

  • (Boolean)


192
193
194
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 192

def return_typed?
  false # raise NotImplementedError
end

#setter?Boolean

Returns:

  • (Boolean)


200
201
202
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 200

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

#sourceObject



204
205
206
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 204

def source
  nil
end

#tagged_as_internal_api?Boolean

Returns:

  • (Boolean)


164
165
166
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 164

def tagged_as_internal_api?
  false
end

#tagged_as_private?Boolean

Returns:

  • (Boolean)


168
169
170
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 168

def tagged_as_private?
  nodoc?
end

#unconsidered_tag_countObject



208
209
210
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 208

def unconsidered_tag_count
  0
end

#undocumented?Boolean

Returns:

  • (Boolean)


212
213
214
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 212

def undocumented?
  @hash['comment'].to_s.empty?
end

#visibilityObject



216
217
218
# File 'lib/inch/language/nodejs/provider/jsdoc/object/base.rb', line 216

def visibility
  docstring.visibility
end