Class: RuboCop::AST::Node

Inherits:
Object
  • Object
show all
Includes:
Cask::Constants
Defined in:
Library/Homebrew/rubocops/cask/extend/node.rb

Overview

Extensions for RuboCop's AST Node class.

Constant Summary

Constants included from Cask::Constants

Cask::Constants::STANZA_GROUPS, Cask::Constants::STANZA_GROUP_HASH, Cask::Constants::STANZA_ORDER

Instance Method Summary collapse

Instance Method Details

#expressionObject


27
28
29
30
31
32
# File 'Library/Homebrew/rubocops/cask/extend/node.rb', line 27

def expression
  base_expression = loc.expression
  descendants.select(&:heredoc?).reduce(base_expression) do |expr, node|
    expr.join(node.loc.heredoc_end)
  end
end

#heredoc?Boolean

Returns:

  • (Boolean)

23
24
25
# File 'Library/Homebrew/rubocops/cask/extend/node.rb', line 23

def heredoc?
  loc.is_a?(Parser::Source::Map::Heredoc)
end

#stanza?Boolean

Returns:

  • (Boolean)

19
20
21
# File 'Library/Homebrew/rubocops/cask/extend/node.rb', line 19

def stanza?
  (send_type? || block_type?) && STANZA_ORDER.include?(method_name)
end