Class: Shhh::App::Output::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/shhh/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(cli) ⇒ Base

Returns a new instance of Base.


9
10
11
# File 'lib/shhh/app/output/base.rb', line 9

def initialize(cli)
  self.cli = cli
end

Class Attribute Details

.outputsObject

Returns the value of attribute outputs


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

def outputs
  @outputs
end

Instance Attribute Details

#cliObject

Returns the value of attribute cli


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

def cli
  @cli
end

Class Method Details

.append(output_klass) ⇒ Object


21
22
23
24
25
# File 'lib/shhh/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/shhh/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/shhh/app/output/base.rb', line 34

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

Instance Method Details

#optsObject


13
14
15
# File 'lib/shhh/app/output/base.rb', line 13

def opts
  cli.opts
end