Class: LanguageServer::Project::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/project/node.rb

Direct Known Subclasses

ConstPathRef, Constant, LiteralValue, Module, VarRef

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attribute_namesObject



19
20
21
# File 'lib/language_server/project/node.rb', line 19

def attribute_names
  @attribute_names ||= superclass.respond_to?(:attribute_names) ? superclass.attribute_names.dup : []
end

.attributes(*attrs) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/language_server/project/node.rb', line 5

def attributes(*attrs)
  attr_accessor(*attrs)
  attribute_names.concat(attrs)
  class_eval "def initialize(\#{attribute_names.map {|n| \"\#{n}:\" }.join(',')})\n  \#{\n    attribute_names.map {|n|\n      \"@\#{n} = \#{n}\"\n    }.join(\"\\n\")\n  }\nend\n  RUBY\nend\n", __FILE__, __LINE__

Instance Method Details

#==(other) ⇒ Object



33
34
35
# File 'lib/language_server/project/node.rb', line 33

def ==(other)
  eql?(other)
end

#attributesObject



41
42
43
44
45
# File 'lib/language_server/project/node.rb', line 41

def attributes
  self.class.attribute_names.map {|a|
    [a, public_send(a)]
  }.to_h
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/language_server/project/node.rb', line 29

def eql?(other)
  other.instance_of?(self.class) && attributes == other.attributes
end

#hashObject



37
38
39
# File 'lib/language_server/project/node.rb', line 37

def hash
  self.attributes.hash
end

#local_pathObject



27
# File 'lib/language_server/project/node.rb', line 27

def local_path;  path.local_path;  end

#remote_pathObject



26
# File 'lib/language_server/project/node.rb', line 26

def remote_path; path.remote_path; end