module RuboCop::Cop::Heredoc
Common functionality for working with heredoc strings.
Constants
- OPENING_DELIMITER
Public Instance Methods
on_heredoc(_node)
click to toggle source
# File lib/rubocop/cop/mixin/heredoc.rb, line 17 def on_heredoc(_node) raise NotImplementedError end
on_str(node)
click to toggle 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
delimiter_string(node)
click to toggle source
# File lib/rubocop/cop/mixin/heredoc.rb, line 28 def delimiter_string(node) node.source.match(OPENING_DELIMITER).captures[1] end
heredoc_type(node)
click to toggle source
# File lib/rubocop/cop/mixin/heredoc.rb, line 32 def heredoc_type(node) node.source.match(OPENING_DELIMITER).captures[0] end
indent_level(str)
click to toggle 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