Class: Yoda::AST::RootVnode

Inherits:
Vnode
  • Object
show all
Includes:
Namespace
Defined in:
lib/yoda/ast/root_vnode.rb

Instance Attribute Summary collapse

Attributes inherited from Vnode

#comments_by_node

Instance Method Summary collapse

Methods included from Namespace

#namespace, #namespace?, #namespace_nestings, #parent_namespace, #path, #root?

Methods inherited from Vnode

#constant?, #empty?, #inspect, #inspect_content, #nesting, #present?, #try, #wrap_child

Methods included from Vnode::CommentPositional

#comments_by_vnode, #positionally_nearest_comment, #positionally_nearest_commenting_node

Methods included from Vnode::Positional

#location, #positionally_include?, #positionally_nearest_child, #range

Methods included from Vnode::CommentAssociation

#all_nodes_lazy, #associate_comments, #comments, #wrapping?

Methods included from Traversable

#query, #query_all, #query_ancestor, #query_ancestors

Methods included from MethodTraversable

#calc_current_location_method, #including_method, #method?

Methods included from NamespaceTraversable

#calc_current_location_namespace, #full_name, #namespace, #namespace?, #namespace_path, #root?

Constructor Details

#initialize(node, comments_by_node: {}) ⇒ RootVnode

Returns a new instance of RootVnode.

Parameters:

  • node (Parser::AST::Node)
  • comment_by_node (Hash{Parser::AST::Node => Array<Parser::Source::Comment>})


11
12
13
14
# File 'lib/yoda/ast/root_vnode.rb', line 11

def initialize(node, comments_by_node: {})
  @node = node
  @comments_by_node = comments_by_node
end

Instance Attribute Details

#nodeParser::AST::Node (readonly)

Returns:

  • (Parser::AST::Node)


7
8
9
# File 'lib/yoda/ast/root_vnode.rb', line 7

def node
  @node
end

Instance Method Details

#childrenArray<Vnode>

Returns:



32
33
34
# File 'lib/yoda/ast/root_vnode.rb', line 32

def children
  [content]
end

#contentVnode

Returns:



27
28
29
# File 'lib/yoda/ast/root_vnode.rb', line 27

def content
  @content ||= wrap_child(node)
end

#identifierString

Returns:

  • (String)


37
38
39
# File 'lib/yoda/ast/root_vnode.rb', line 37

def identifier
  "#{type}:#{source_map.expression}"
end

#parentnil

Returns:

  • (nil)


17
18
19
# File 'lib/yoda/ast/root_vnode.rb', line 17

def parent
  nil
end

#source_mapParser::Source::Map?

Returns:

  • (Parser::Source::Map, nil)


42
43
44
# File 'lib/yoda/ast/root_vnode.rb', line 42

def source_map
  node.location
end

#typeSymbol

Returns:

  • (Symbol)


22
23
24
# File 'lib/yoda/ast/root_vnode.rb', line 22

def type
  :root
end