Class: LanguageServer::Project::Node
- Inherits:
-
Object
- Object
- LanguageServer::Project::Node
show all
- Defined in:
- lib/language_server/project/node.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.attribute_names ⇒ Object
17
18
19
|
# File 'lib/language_server/project/node.rb', line 17
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
|
# File 'lib/language_server/project/node.rb', line 5
def attributes(*attrs)
attr_accessor(*attrs)
attribute_names.concat(attrs)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def initialize(#{attribute_names.map { |n| "#{n}:" }.join(",")})
#{attribute_names.map { |n|
"@#{n} = #{n}"
}.join("\n")}
end
RUBY
end
|
Instance Method Details
#==(other) ⇒ Object
36
37
38
|
# File 'lib/language_server/project/node.rb', line 36
def ==(other)
eql?(other)
end
|
#attributes ⇒ Object
44
45
46
47
48
|
# File 'lib/language_server/project/node.rb', line 44
def attributes
self.class.attribute_names.map { |a|
[a, public_send(a)]
}.to_h
end
|
#eql?(other) ⇒ Boolean
32
33
34
|
# File 'lib/language_server/project/node.rb', line 32
def eql?(other)
other.instance_of?(self.class) && attributes == other.attributes
end
|
#hash ⇒ Object
40
41
42
|
# File 'lib/language_server/project/node.rb', line 40
def hash
self.attributes.hash
end
|
#local_path ⇒ Object
28
29
30
|
# File 'lib/language_server/project/node.rb', line 28
def local_path
path.local_path
end
|
#remote_path ⇒ Object
24
25
26
|
# File 'lib/language_server/project/node.rb', line 24
def remote_path
path.remote_path
end
|