Class: CP::HighLine

Inherits:
HighLine
  • Object
show all
Includes:
Singleton
Defined in:
lib/cp/highline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#formatObject

Returns the value of attribute format.



8
9
10
# File 'lib/cp/highline.rb', line 8

def format
  @format
end

Instance Method Details

#say(statement = "") ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cp/highline.rb', line 15

def say( statement="" )
  @output = $stdout # because we override $stdout for testing

  if !@buffer.nil?
    @buffer << statement
  else
    formatter = "to_#{format}".to_sym
    statement = statement.respond_to?( formatter ) ? statement.send( formatter ) : statement.to_s
    super( statement )
  end
end

#say_bufferObject



27
28
29
30
31
32
33
34
# File 'lib/cp/highline.rb', line 27

def say_buffer
  if !@buffer.nil? && @buffer.size > 0
    statement = @buffer
    @buffer = nil
    say( statement.size === 1 ? statement.first : statement )
    @buffer = []
  end
end