Class: Cask::DSL::Caveats Private
- Defined in:
- Library/Homebrew/cask/dsl/caveats.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class corresponding to the caveats
stanza.
Each method should handle output, following the convention of at least one trailing blank line so that the user can distinguish separate caveats.
The return value of the last method in the block is also sent to the output by the caller, but that feature is only for the convenience of cask authors.
Instance Method Summary collapse
- #eval_caveats(&block) ⇒ Object private
-
#initialize(*args) ⇒ Caveats
constructor
private
A new instance of Caveats.
-
#puts(*args) ⇒ Object
private
Override
puts
to collect caveats. - #to_s ⇒ Object private
Methods inherited from Base
#method_missing, #system_command
Constructor Details
#initialize(*args) ⇒ Caveats
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Caveats.
18 19 20 21 22 |
# File 'Library/Homebrew/cask/dsl/caveats.rb', line 18 def initialize(*args) super(*args) @built_in_caveats = {} @custom_caveats = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Cask::DSL::Base
Instance Method Details
#eval_caveats(&block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 49 50 51 |
# File 'Library/Homebrew/cask/dsl/caveats.rb', line 45 def eval_caveats(&block) result = instance_eval(&block) return unless result return if result == :built_in_caveat @custom_caveats << result.to_s.sub(/\s*\Z/, "\n") end |
#puts(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Override puts
to collect caveats.
40 41 42 43 |
# File 'Library/Homebrew/cask/dsl/caveats.rb', line 40 def puts(*args) @custom_caveats += args :built_in_caveat end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 |
# File 'Library/Homebrew/cask/dsl/caveats.rb', line 35 def to_s (@custom_caveats + @built_in_caveats.values).join("\n") end |