Module: Kernel

Defined in:
lib/antlr3/test/call-stack.rb,
lib/antlr3/test/core-extensions.rb

Instance Method Summary collapse

Instance Method Details

#call_stack(depth = 1) ⇒ Object


46
47
48
# File 'lib/antlr3/test/call-stack.rb', line 46

def call_stack( depth = 1 )
  Call.convert_backtrace( caller( depth + 1 ) )
end

#screen_width(out = STDERR) ⇒ Object


161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/antlr3/test/core-extensions.rb', line 161

def screen_width( out=STDERR )
  default_width = ENV[ 'COLUMNS' ] || 80
  tiocgwinsz = 0x5413
  data = [ 0, 0, 0, 0 ].pack( "SSSS" )
  if out.ioctl( tiocgwinsz, data ) >= 0 then
    rows, cols, xpixels, ypixels = data.unpack( "SSSS" )
    if cols >= 0 then cols else default_width end
  else
    default_width
  end
rescue Exception => e
  default_width rescue ( raise e )
end