Class: Parser::Source::Range

Inherits:
Object
  • Object
show all
Defined in:
lib/deep_cover/parser_ext/range.rb

Instance Method Summary collapse

Instance Method Details

#succObject



4
5
6
# File 'lib/deep_cover/parser_ext/range.rb', line 4

def succ
  adjust(begin_pos: +1, end_pos: +1)
end

#wrap_rwhitespace(whitespaces: /\A\s+/) ⇒ Object



8
9
10
11
# File 'lib/deep_cover/parser_ext/range.rb', line 8

def wrap_rwhitespace(whitespaces: /\A\s+/)
  whitespace = @source_buffer.slice(end_pos..-1)[whitespaces] || ''
  adjust(end_pos: whitespace.size)
end

#wrap_rwhitespace_and_comments(whitespaces: /\A\s+/) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/deep_cover/parser_ext/range.rb', line 13

def wrap_rwhitespace_and_comments(whitespaces: /\A\s+/)
  current = wrap_rwhitespace(whitespaces: whitespaces)
  while @source_buffer.slice(current.end_pos) == '#'
    comment = @source_buffer.slice(current.end_pos..-1)[/\A[^\n]+/] || ''
    current = current.adjust(end_pos: comment.size).wrap_rwhitespace(whitespaces: whitespaces)
  end
  current
end