Class: RuboCop::Cask::AST::CaskHeader Private
- Defined in:
- rubocops/cask/ast/cask_header.rb
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 method node that represents the cask header. It includes various helper methods to aid cops in their analysis.
Instance Attribute Summary collapse
- #method_node ⇒ T.all(RuboCop::AST::Node, RuboCop::AST::ParameterizedNode::RestArguments) readonly private
Instance Method Summary collapse
- #cask_token ⇒ String private
- #hash_node ⇒ T.all(RuboCop::AST::Node, RuboCop::AST::ParameterizedNode::RestArguments) private
- #header_str ⇒ String private
- #initialize(method_node) ⇒ void constructor private
- #pair_node ⇒ T.all(RuboCop::AST::Node, RuboCop::AST::ParameterizedNode::RestArguments) private
- #preferred_header_str ⇒ String private
- #source_range ⇒ Parser::Source::Range private
Constructor Details
#initialize(method_node) ⇒ void
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.
11 12 13 |
# File 'rubocops/cask/ast/cask_header.rb', line 11 def initialize(method_node) @method_node = method_node end |
Instance Attribute Details
#method_node ⇒ T.all(RuboCop::AST::Node, RuboCop::AST::ParameterizedNode::RestArguments) (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.
16 17 18 |
# File 'rubocops/cask/ast/cask_header.rb', line 16 def method_node @method_node end |
Instance Method Details
#cask_token ⇒ String
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.
34 35 36 |
# File 'rubocops/cask/ast/cask_header.rb', line 34 def cask_token @cask_token ||= T.let(method_node.first_argument.str_content, T.nilable(String)) end |
#hash_node ⇒ T.all(RuboCop::AST::Node, RuboCop::AST::ParameterizedNode::RestArguments)
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.
39 40 41 |
# File 'rubocops/cask/ast/cask_header.rb', line 39 def hash_node @hash_node ||= T.let(method_node.each_child_node(:hash).first, T.nilable(RuboCop::AST::Node)) end |
#header_str ⇒ String
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 20 21 |
# File 'rubocops/cask/ast/cask_header.rb', line 19 def header_str @header_str ||= T.let(source_range.source, T.nilable(String)) end |
#pair_node ⇒ T.all(RuboCop::AST::Node, RuboCop::AST::ParameterizedNode::RestArguments)
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.
44 45 46 |
# File 'rubocops/cask/ast/cask_header.rb', line 44 def pair_node @pair_node ||= T.let(hash_node.each_child_node(:pair).first, T.nilable(RuboCop::AST::Node)) end |
#preferred_header_str ⇒ String
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.
29 30 31 |
# File 'rubocops/cask/ast/cask_header.rb', line 29 def preferred_header_str "cask '#{cask_token}'" end |
#source_range ⇒ Parser::Source::Range
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.
24 25 26 |
# File 'rubocops/cask/ast/cask_header.rb', line 24 def source_range @source_range ||= T.let(method_node.loc.expression, T.nilable(Parser::Source::Range)) end |