Class: RuboCop::Cask::AST::Stanza Private
- Extended by:
- Forwardable
- Defined in:
- rubocops/cask/ast/stanza.rb,
sorbet/rbi/dsl/rubo_cop/cask/ast/stanza.rbi
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
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.
Instance Attribute Summary collapse
- #all_comments ⇒ Object readonly private
- #method_node ⇒ Object (also: #stanza_node) readonly private
Instance Method Summary collapse
- #arch_variable?(*args, &block) ⇒ Boolean private
- #comments ⇒ Object private
- #comments_hash ⇒ Object private
-
#initialize(method_node, all_comments) ⇒ Stanza
constructor
private
A new instance of Stanza.
- #on_system_block?(*args, &block) ⇒ Boolean private
- #parent_node(*args, &block) ⇒ T.untyped private
- #same_group?(other) ⇒ Boolean private
- #source(*args, &block) ⇒ T.untyped private
- #source_range ⇒ Object private
- #source_range_with_comments ⇒ Object private
- #source_with_comments(*args, &block) ⇒ T.untyped private
- #stanza_group ⇒ Object private
- #stanza_index ⇒ Object private
- #stanza_name ⇒ Object private
Constructor Details
#initialize(method_node, all_comments) ⇒ Stanza
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a new instance of Stanza.
15 16 17 18 |
# File 'rubocops/cask/ast/stanza.rb', line 15 def initialize(method_node, all_comments) @method_node = method_node @all_comments = all_comments end |
Instance Attribute Details
#all_comments ⇒ Object (readonly)
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
20 21 22 |
# File 'rubocops/cask/ast/stanza.rb', line 20 def all_comments @all_comments end |
#method_node ⇒ Object (readonly) Also known as: stanza_node
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
20 21 22 |
# File 'rubocops/cask/ast/stanza.rb', line 20 def method_node @method_node end |
Instance Method Details
#arch_variable?(*args, &block) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 |
# File 'sorbet/rbi/dsl/rubo_cop/cask/ast/stanza.rbi', line 10 def arch_variable?(*args, &block); end |
#comments ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
60 61 62 63 64 |
# File 'rubocops/cask/ast/stanza.rb', line 60 def comments @comments ||= stanza_node.each_node.reduce([]) do |comments, node| comments | comments_hash[node.loc] end end |
#comments_hash ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
66 67 68 |
# File 'rubocops/cask/ast/stanza.rb', line 66 def comments_hash @comments_hash ||= Parser::Source::Comment.associate_locations(stanza_node.parent, all_comments) end |
#on_system_block?(*args, &block) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
13 |
# File 'sorbet/rbi/dsl/rubo_cop/cask/ast/stanza.rbi', line 13 def on_system_block?(*args, &block); end |
#parent_node(*args, &block) ⇒ T.untyped
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
16 |
# File 'sorbet/rbi/dsl/rubo_cop/cask/ast/stanza.rbi', line 16 def parent_node(*args, &block); end |
#same_group?(other) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
56 57 58 |
# File 'rubocops/cask/ast/stanza.rb', line 56 def same_group?(other) stanza_group == other.stanza_group end |
#source(*args, &block) ⇒ T.untyped
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
19 |
# File 'sorbet/rbi/dsl/rubo_cop/cask/ast/stanza.rbi', line 19 def source(*args, &block); end |
#source_range ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
28 29 30 |
# File 'rubocops/cask/ast/stanza.rb', line 28 def source_range stanza_node.location_expression end |
#source_range_with_comments ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
32 33 34 35 36 |
# File 'rubocops/cask/ast/stanza.rb', line 32 def source_range_with_comments comments.reduce(source_range) do |range, comment| range.join(comment.loc.expression) end end |
#source_with_comments(*args, &block) ⇒ T.untyped
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
22 |
# File 'sorbet/rbi/dsl/rubo_cop/cask/ast/stanza.rbi', line 22 def source_with_comments(*args, &block); end |
#stanza_group ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
48 49 50 |
# File 'rubocops/cask/ast/stanza.rb', line 48 def stanza_group Constants::STANZA_GROUP_HASH[stanza_name] end |
#stanza_index ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
52 53 54 |
# File 'rubocops/cask/ast/stanza.rb', line 52 def stanza_index Constants::STANZA_ORDER.index(stanza_name) end |
#stanza_name ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
42 43 44 45 46 |
# File 'rubocops/cask/ast/stanza.rb', line 42 def stanza_name return :on_arch_conditional if arch_variable? stanza_node.method_name end |