Class: Solargraph::Source::NodeChainer

Inherits:
Object
  • Object
show all
Includes:
NodeMethods
Defined in:
lib/solargraph/source/node_chainer.rb

Overview

A factory for generating chains from nodes.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NodeMethods

const_from, drill_signature, get_node_end_position, get_node_start_position, infer_literal_node_type, pack_name, resolve_node_signature, returns_from, unpack_name

Constructor Details

#initialize(node, filename = nil) ⇒ NodeChainer


10
11
12
13
# File 'lib/solargraph/source/node_chainer.rb', line 10

def initialize node, filename = nil
  @node = node
  @filename = filename
end

Class Method Details

.chain(node, filename = nil) ⇒ Chain


25
26
27
# File 'lib/solargraph/source/node_chainer.rb', line 25

def chain node, filename = nil
  NodeChainer.new(node, filename).chain
end

.load_string(code) ⇒ Chain


31
32
33
34
35
36
# File 'lib/solargraph/source/node_chainer.rb', line 31

def load_string(code)
  node = Source.parse(code.sub(/\.$/, ''))
  chain = NodeChainer.new(node).chain
  chain.links.push(Chain::Link.new) if code.end_with?('.')
  chain
end

Instance Method Details

#chainSource::Chain


16
17
18
19
# File 'lib/solargraph/source/node_chainer.rb', line 16

def chain
  links = generate_links(@node)
  Chain.new(links)
end