Module: Yerba::Node

Included in:
Map, Scalar, Sequence
Defined in:
lib/yerba/node.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/yerba/node.rb', line 5

def key
  @key
end

#locationObject (readonly)

Returns the value of attribute location.



5
6
7
# File 'lib/yerba/node.rb', line 5

def location
  @location
end

#selectorObject (readonly)

Returns the value of attribute selector.



5
6
7
# File 'lib/yerba/node.rb', line 5

def selector
  @selector
end

Class Method Details

.included(base) ⇒ Object



43
44
45
# File 'lib/yerba/node.rb', line 43

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#connected?Boolean

Returns:

  • (Boolean)


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

def connected?
  !@document.nil? || !@file_path.nil?
end

#documentObject



15
16
17
# File 'lib/yerba/node.rb', line 15

def document
  @document ||= @file_path ? Yerba::Document.cache[@file_path] : nil
end

#file_pathObject



7
8
9
# File 'lib/yerba/node.rb', line 7

def file_path
  @file_path || @document&.path
end

#lineObject



11
12
13
# File 'lib/yerba/node.rb', line 11

def line
  @line || @location&.start_line
end