A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://ruby-syntax-tree.github.io/syntax_tree/SyntaxTree/Heredoc.html below:

class SyntaxTree::Heredoc - RDoc Documentation

  1. SyntaxTree::
  2. Heredoc
class SyntaxTree::Heredoc

Heredoc represents a heredoc string literal.

<<~DOC
  contents
DOC
Constants
SEPARATOR

This is a very specific behavior where you want to force a newline, but don’t want to force the break parent.

Attributes
Integer

how far to dedent the heredoc

Public Class Methods

Source

def initialize(beginning:, location:, ending: nil, dedent: 0, parts: [])
  @beginning = beginning
  @ending = ending
  @dedent = dedent
  @parts = parts
  @location = location
  @comments = []
end
Public Instance Methods

Source

def ===(other)
  other.is_a?(Heredoc) && beginning === other.beginning &&
    ending === other.ending && ArrayMatch.call(parts, other.parts)
end

Source

def accept(visitor)
  visitor.visit_heredoc(self)
end

Source

def child_nodes
  [beginning, *parts, ending]
end

Source

def copy(beginning: nil, location: nil, ending: nil, parts: nil)
  node =
    Heredoc.new(
      beginning: beginning || self.beginning,
      location: location || self.location,
      ending: ending || self.ending,
      parts: parts || self.parts
    )

  node.comments.concat(comments.map(&:copy))
  node
end

Source

def deconstruct_keys(_keys)
  {
    beginning: beginning,
    location: location,
    ending: ending,
    parts: parts,
    comments: comments
  }
end

Source

def format(q)
  q.group do
    q.format(beginning)

    q.line_suffix(priority: Formatter::HEREDOC_PRIORITY) do
      q.group do
        q.target << SEPARATOR

        parts.each do |part|
          if part.is_a?(TStringContent)
            value = part.value
            first = true

            value.each_line(chomp: true) do |line|
              if first
                first = false
              else
                q.target << SEPARATOR
              end

              q.text(line)
            end

            q.target << SEPARATOR if value.end_with?("\n")
          else
            q.format(part)
          end
        end

        q.format(ending)
      end
    end
  end
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4