Module: DbAgile::Environment::Buffering

Included in:
DbAgile::Environment
Defined in:
lib/dbagile/environment/buffering.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#input_bufferObject

The output buffer to use for user requests



6
7
8
# File 'lib/dbagile/environment/buffering.rb', line 6

def input_buffer
  @input_buffer
end

#output_bufferObject

The output buffer to use for display



9
10
11
# File 'lib/dbagile/environment/buffering.rb', line 9

def output_buffer
  @output_buffer
end

Instance Method Details

#flush(something, append_new_line = true) ⇒ void

This method returns an undefined value.

Flushes something on the output buffer

Does nothing when no output buffer has been set.

Parameters:

  • something (Object)

    to write on environment output



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dbagile/environment/buffering.rb', line 19

def flush(something, append_new_line = true)
  unless output_buffer.nil?
    if something.kind_of?(String)
      output_buffer << something
      if append_new_line and not(something =~ /\n$/)
        output_buffer << "\n"
      end
    elsif something.kind_of?(Enumerable)
      something.each{|v| flush(v, true)}
    else
      flush(something.to_s)
    end
  end
  nil
end

#getsObject

Delegated to the input buffer. Returns nil if no input buffer has been set



39
40
41
# File 'lib/dbagile/environment/buffering.rb', line 39

def gets
  input_buffer.nil? ? nil : input_buffer.gets
end