Class: Hbc::DSL::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
Library/Homebrew/cask/lib/hbc/dsl/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(cask, command = SystemCommand) ⇒ Base

Returns a new instance of Base



6
7
8
9
# File 'Library/Homebrew/cask/lib/hbc/dsl/base.rb', line 6

def initialize(cask, command = SystemCommand)
  @cask = cask
  @command = command
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'Library/Homebrew/cask/lib/hbc/dsl/base.rb', line 17

def method_missing(method, *)
  if method
    underscored_class = self.class.name.gsub(/([[:lower:]])([[:upper:]][[:lower:]])/, '\1_\2').downcase
    section = underscored_class.split("::").last
    Utils.method_missing_message(method, @cask.to_s, section)
    nil
  else
    super
  end
end

Instance Method Details

#respond_to_missing?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'Library/Homebrew/cask/lib/hbc/dsl/base.rb', line 28

def respond_to_missing?(*)
  true
end

#system_command(executable, **options) ⇒ Object



13
14
15
# File 'Library/Homebrew/cask/lib/hbc/dsl/base.rb', line 13

def system_command(executable, **options)
  @command.run!(executable, **options)
end