Module: Prism::LexCompat::Heredoc

Defined in:
lib/prism/lex_compat.rb

Overview

A heredoc in this case is a list of tokens that belong to the body of the heredoc that should be appended onto the list of tokens when the heredoc closes.

Defined Under Namespace

Classes: DashHeredoc, DedentingHeredoc, PlainHeredoc

Class Method Summary collapse

Class Method Details

.build(opening) ⇒ Object

Here we will split between the two types of heredocs and return the object that will store their tokens.



541
542
543
544
545
546
547
548
549
550
# File 'lib/prism/lex_compat.rb', line 541

def self.build(opening)
  case opening.value[2]
  when "~"
    DedentingHeredoc.new
  when "-"
    DashHeredoc.new(opening.value[3] != "'")
  else
    PlainHeredoc.new
  end
end