Class: Yap::Shell::Parser::Nodes::CommandNode

Inherits:
Object
  • Object
show all
Includes:
Visitor
Defined in:
lib/yap/shell/parser/nodes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Visitor

#accept

Constructor Details

#initialize(token, *args, literal: false, heredoc: nil) ⇒ CommandNode

Returns a new instance of CommandNode.



58
59
60
61
62
63
64
# File 'lib/yap/shell/parser/nodes.rb', line 58

def initialize(token, *args, literal:false, heredoc:nil)
  @command = token.value
  @args = args.flatten
  @literal = literal
  @heredoc = nil
  @redirects = []
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



55
56
57
# File 'lib/yap/shell/parser/nodes.rb', line 55

def args
  @args
end

#commandObject (readonly)

Returns the value of attribute command.



55
56
57
# File 'lib/yap/shell/parser/nodes.rb', line 55

def command
  @command
end

#heredocObject

Returns the value of attribute heredoc.



56
57
58
# File 'lib/yap/shell/parser/nodes.rb', line 56

def heredoc
  @heredoc
end

#redirectsObject

Returns the value of attribute redirects.



56
57
58
# File 'lib/yap/shell/parser/nodes.rb', line 56

def redirects
  @redirects
end

Instance Method Details

#heredoc?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/yap/shell/parser/nodes.rb', line 70

def heredoc?
  @heredoc
end

#inspectObject



78
79
80
# File 'lib/yap/shell/parser/nodes.rb', line 78

def inspect
  to_s
end

#internally_evaluate?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/yap/shell/parser/nodes.rb', line 74

def internally_evaluate?
  false
end

#literal?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/yap/shell/parser/nodes.rb', line 66

def literal?
  @literal
end

#to_sObject



82
83
84
# File 'lib/yap/shell/parser/nodes.rb', line 82

def to_s
  "CommandNode(#{@command}, args: #{@args}, literal:#{literal?}, heredoc: #{heredoc?}, redirects: #{redirects})"
end