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 ⇒ Object readonly private
Instance Method Summary collapse
- #cask_token ⇒ Object private
- #hash_node ⇒ Object private
- #header_str ⇒ Object private
-
#initialize(method_node) ⇒ CaskHeader
constructor
private
A new instance of CaskHeader.
- #pair_node ⇒ Object private
- #preferred_header_str ⇒ String private
- #source_range ⇒ Object private
Constructor Details
#initialize(method_node) ⇒ CaskHeader
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 CaskHeader.
10 11 12 |
# File 'rubocops/cask/ast/cask_header.rb', line 10 def initialize(method_node) @method_node = method_node end |
Instance Attribute Details
#method_node ⇒ 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.
14 15 16 |
# File 'rubocops/cask/ast/cask_header.rb', line 14 def method_node @method_node end |
Instance Method Details
#cask_token ⇒ 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.
29 30 31 |
# File 'rubocops/cask/ast/cask_header.rb', line 29 def cask_token @cask_token ||= method_node.first_argument.str_content end |
#hash_node ⇒ 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.
33 34 35 |
# File 'rubocops/cask/ast/cask_header.rb', line 33 def hash_node @hash_node ||= method_node.each_child_node(:hash).first end |
#header_str ⇒ 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.
16 17 18 |
# File 'rubocops/cask/ast/cask_header.rb', line 16 def header_str @header_str ||= source_range.source end |
#pair_node ⇒ 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.
37 38 39 |
# File 'rubocops/cask/ast/cask_header.rb', line 37 def pair_node @pair_node ||= hash_node.each_child_node(:pair).first 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.
25 26 27 |
# File 'rubocops/cask/ast/cask_header.rb', line 25 def preferred_header_str "cask '#{cask_token}'" 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.
20 21 22 |
# File 'rubocops/cask/ast/cask_header.rb', line 20 def source_range @source_range ||= method_node.loc.expression end |