module RuboCop::Cop::Heredoc
Common functionality for working with heredoc strings.
Constants
- OPENING_DELIMITER
Public Instance Methods
Source
# File lib/rubocop/cop/mixin/heredoc.rb, line 17 def on_heredoc(_node) raise NotImplementedError end
Source
# File lib/rubocop/cop/mixin/heredoc.rb, line 9 def on_str(node) return unless node.heredoc? on_heredoc(node) end
Private Instance Methods
Source
# File lib/rubocop/cop/mixin/heredoc.rb, line 28 def delimiter_string(node) return '' unless (match = node.source.match(OPENING_DELIMITER)) match.captures[1] end
Source
# File lib/rubocop/cop/mixin/heredoc.rb, line 34 def heredoc_type(node) return '' unless (match = node.source.match(OPENING_DELIMITER)) match.captures[0] end
Source
# File lib/rubocop/cop/mixin/heredoc.rb, line 23 def indent_level(str) indentations = str.lines.map { |line| line[/^\s*/] }.reject { |line| line.end_with?("\n") } indentations.empty? ? 0 : indentations.min_by(&:size).size end