class Pechkin::Command::Base

Basic class for all commands

Attributes

options[R]

Public Class Methods

new(options, stdout: STDOUT, stderr: STDERR) click to toggle source

Initializes command state @param options [OpenStruct] set of options which allows to configure

command behaviour

@opt stdout [IO] IO object which represents STDOUT @opt stderr [IO] IO object which represents STDERR

# File lib/pechkin/command/base.rb, line 12
def initialize(options, stdout: STDOUT, stderr: STDERR)
  @options = options
  @stdout = stdout
  @stderr = stderr
end

Public Instance Methods

configuration() click to toggle source
# File lib/pechkin/command/base.rb, line 18
def configuration
  config_dir = options.config_dir
  @configuration ||= Configuration.load_from_directory(config_dir)
end
handler() click to toggle source
# File lib/pechkin/command/base.rb, line 23
def handler
  @handler ||= Handler.new(configuration.channels)
end
matches?() click to toggle source
# File lib/pechkin/command/base.rb, line 27
def matches?
  raise 'Unimplemented'
end
puts(*args) click to toggle source
# File lib/pechkin/command/base.rb, line 31
def puts(*args)
  @stdout.puts(*args)
end
warn(*args) click to toggle source
# File lib/pechkin/command/base.rb, line 35
def warn(*args)
  @stderr.puts(*args)
end