Class: Sourcify::Proc::Scanner::Heredoc

Inherits:
Struct
  • Object
show all
Defined in:
lib/sourcify/proc/scanner/heredoc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#indentedObject

Returns the value of attribute indented

Returns:

  • (Object)

    the current value of indented



4
5
6
# File 'lib/sourcify/proc/scanner/heredoc.rb', line 4

def indented
  @indented
end

#tagObject

Returns the value of attribute tag

Returns:

  • (Object)

    the current value of tag



4
5
6
# File 'lib/sourcify/proc/scanner/heredoc.rb', line 4

def tag
  @tag
end

Instance Method Details

#<<(content) ⇒ Object



6
7
8
# File 'lib/sourcify/proc/scanner/heredoc.rb', line 6

def <<(content)
  (@contents ||= []) << content
end

#closed?(sealer) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
# File 'lib/sourcify/proc/scanner/heredoc.rb', line 14

def closed?(sealer)
  return false unless sealer == "\n"
  parts = @contents[-1].split("\n")
  return true if parts[-1] == tag
  indented && parts[-1].sub(/^\s*(.*)$/,'\1') == tag
end

#to_sObject



10
11
12
# File 'lib/sourcify/proc/scanner/heredoc.rb', line 10

def to_s
  @contents.join
end