Class: Apical::ConsoleWriter
- Inherits:
-
Object
- Object
- Apical::ConsoleWriter
- Defined in:
- lib/apical/writers/console_writer.rb
Instance Method Summary collapse
-
#initialize(runner) ⇒ ConsoleWriter
constructor
A new instance of ConsoleWriter.
- #resource_text(resource) ⇒ Object
- #write(stream) ⇒ Object
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 |