Class: Metaphor

Inherits:
Object
  • Object
show all
Defined in:
lib/metaphor.rb,
lib/metaphor/processor/detour.rb,
lib/metaphor/input/stdin_input.rb,
lib/metaphor/processor/wiretap.rb,
lib/metaphor/processor/print_message.rb,
lib/metaphor/processor/json_processor.rb

Defined Under Namespace

Modules: Input, Processor

Constant Summary collapse

VERSION =
'1.0.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMetaphor

Returns a new instance of Metaphor.



5
6
7
# File 'lib/metaphor.rb', line 5

def initialize
  self.processors = []
end

Instance Attribute Details

#processorsObject

Returns the value of attribute processors.



3
4
5
# File 'lib/metaphor.rb', line 3

def processors
  @processors
end

Instance Method Details

#call(input) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/metaphor.rb', line 9

def call(input)
  if input.respond_to?(:gets)
    while message = input.gets
      process_message message
    end
  else
    process_message input
  end
end