Class: Sourcify::Common::Parser::RawScanner::Heredoc

Inherits:
Struct
  • Object
show all
Defined in:
lib/sourcify/lib/sourcify/common/parser/raw_scanner/heredoc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#encodingObject

Returns the value of attribute encoding

Returns:

  • (Object)

    the current value of encoding



5
6
7
# File 'lib/sourcify/lib/sourcify/common/parser/raw_scanner/heredoc.rb', line 5

def encoding
  @encoding
end

#indentedObject

Returns the value of attribute indented

Returns:

  • (Object)

    the current value of indented



5
6
7
# File 'lib/sourcify/lib/sourcify/common/parser/raw_scanner/heredoc.rb', line 5

def indented
  @indented
end

#tagObject

Returns the value of attribute tag

Returns:

  • (Object)

    the current value of tag



5
6
7
# File 'lib/sourcify/lib/sourcify/common/parser/raw_scanner/heredoc.rb', line 5

def tag
  @tag
end

Instance Method Details

#<<(content) ⇒ Object



7
8
9
# File 'lib/sourcify/lib/sourcify/common/parser/raw_scanner/heredoc.rb', line 7

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

#closed?(sealer) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
# File 'lib/sourcify/lib/sourcify/common/parser/raw_scanner/heredoc.rb', line 15

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



11
12
13
# File 'lib/sourcify/lib/sourcify/common/parser/raw_scanner/heredoc.rb', line 11

def to_s
  @contents.join.force_encoding(encoding)
end