Class: RuboCop::AST::Node

Inherits:
Object
  • Object
show all
Includes:
Cask::Constants
Defined in:
brew/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



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

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)


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

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

#stanza?Boolean

Returns:

  • (Boolean)


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

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