Class: Sym::App::Output::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/sym/app/output/base.rb

Direct Known Subclasses

File, Noop, Stdout

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts, stdin = $stdin, stdout = $stdout, stderr = $stderr, kernel = nil) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
# File 'lib/sym/app/output/base.rb', line 9

def initialize(opts, stdin = $stdin, stdout = $stdout, stderr = $stderr, kernel = nil)
  self.opts   = opts
  self.stdin  = stdin
  self.stdout = stdout
  self.stderr = stderr
  self.kernel = kernel
end

Class Attribute Details

.outputsObject

Returns the value of attribute outputs.



19
20
21
# File 'lib/sym/app/output/base.rb', line 19

def outputs
  @outputs
end

Instance Attribute Details

#kernelObject

Returns the value of attribute kernel.



7
8
9
# File 'lib/sym/app/output/base.rb', line 7

def kernel
  @kernel
end

#optsObject

Returns the value of attribute opts.



7
8
9
# File 'lib/sym/app/output/base.rb', line 7

def opts
  @opts
end

#stderrObject

Returns the value of attribute stderr.



7
8
9
# File 'lib/sym/app/output/base.rb', line 7

def stderr
  @stderr
end

#stdinObject

Returns the value of attribute stdin.



7
8
9
# File 'lib/sym/app/output/base.rb', line 7

def stdin
  @stdin
end

#stdoutObject

Returns the value of attribute stdout.



7
8
9
# File 'lib/sym/app/output/base.rb', line 7

def stdout
  @stdout
end

Class Method Details

.append(output_klass) ⇒ Object



21
22
23
24
25
# File 'lib/sym/app/output/base.rb', line 21

def append(output_klass)
  outputs << output_klass if outputs.is_a?(Array)
  raise "Cannot append #{output_class} after #outputs has been converted to a Hash" \
    unless outputs.is_a?(Array)
end

.map_outputs!Object



27
28
29
30
31
32
# File 'lib/sym/app/output/base.rb', line 27

def map_outputs!
  klasses      = self.outputs
  self.outputs = Hash.new
  klasses.each { |k| self.outputs[k.required_option] = k }
  outputs
end

.options_to_outputsObject



34
35
36
37
# File 'lib/sym/app/output/base.rb', line 34

def options_to_outputs
  map_outputs! if outputs.is_a?(Array)
  outputs
end