class RuboCop::Cask::AST::Stanza
This class wraps the AST
send/block node that encapsulates the method call that comprises the stanza. It includes various helper methods to aid cops in their analysis.
Attributes
comments[R]
method_node[R]
stanza_node[R]
Public Class Methods
new(method_node, comments)
click to toggle source
# File lib/rubocop/cask/ast/stanza.rb, line 12 def initialize(method_node, comments) @method_node = method_node @comments = comments end
Public Instance Methods
==(other)
click to toggle source
# File lib/rubocop/cask/ast/stanza.rb, line 50 def ==(other) self.class == other.class && stanza_node == other.stanza_node end
Also aliased as: eql?
same_group?(other)
click to toggle source
# File lib/rubocop/cask/ast/stanza.rb, line 42 def same_group?(other) stanza_group == other.stanza_group end
source_range()
click to toggle source
# File lib/rubocop/cask/ast/stanza.rb, line 24 def source_range stanza_node.expression end
source_range_with_comments()
click to toggle source
# File lib/rubocop/cask/ast/stanza.rb, line 28 def source_range_with_comments comments.reduce(source_range) do |range, comment| range.join(comment.loc.expression) end end
stanza_group()
click to toggle source
# File lib/rubocop/cask/ast/stanza.rb, line 38 def stanza_group Constants::STANZA_GROUP_HASH[stanza_name] end
toplevel_stanza?()
click to toggle source
# File lib/rubocop/cask/ast/stanza.rb, line 46 def toplevel_stanza? parent_node.cask_block? || parent_node.parent.cask_block? end