class SyntaxTree::EndContent
EndContent
represents the use of __END__ syntax, which allows individual scripts to keep content after the main ruby code that can be read through the DATA constant.
puts DATA.read __END__
Attributes
value[R]
- String
-
the content after the script
Public Class Methods
new(value:, location:)
click to toggle source
# File lib/syntax_tree/node.rb, line 393 def initialize(value:, location:) @value = value @location = location @comments = [] end
Public Instance Methods
===(other)
click to toggle source
# File lib/syntax_tree/node.rb, line 442 def ===(other) other.is_a?(EndContent) && value === other.value end
accept(visitor)
click to toggle source
# File lib/syntax_tree/node.rb, line 399 def accept(visitor) visitor.visit___end__(self) end
child_nodes()
click to toggle source
# File lib/syntax_tree/node.rb, line 403 def child_nodes [] end
Also aliased as: deconstruct
copy(value: nil, location: nil)
click to toggle source
# File lib/syntax_tree/node.rb, line 407 def copy(value: nil, location: nil) node = EndContent.new( value: value || self.value, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/node.rb, line 420 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end
format(q)
click to toggle source
# File lib/syntax_tree/node.rb, line 424 def format(q) q.text("__END__") q.breakable_force first = true value.each_line(chomp: true) do |line| if first first = false else q.breakable_return end q.text(line) end q.breakable_return if value.end_with?("\n") end