Class: Apical::ConsoleWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/apical/writers/console_writer.rb

Instance Method Summary collapse

Constructor Details

#initialize(runner) ⇒ ConsoleWriter

Returns a new instance of ConsoleWriter.



3
4
5
# File 'lib/apical/writers/console_writer.rb', line 3

def initialize(runner)
  @runner = runner
end

Instance Method Details

#resource_text(resource) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/apical/writers/console_writer.rb', line 15

def resource_text(resource)
  <<-TXT
    method:   #{resource.method}
    path:     #{resource.path}
    desc:     #{resource.desc}
    params:   #{resource.formatted_params}
    response: #{resource.formatted_response}

  TXT
end

#write(stream) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/apical/writers/console_writer.rb', line 7

def write(stream)
  @runner.run

  stream.write( @runner.resources.map{|r| resource_text(r) }.join )
  stream.rewind if @runner.resources.any?
  stream
end