Class: TTY::Terminal

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/terminal.rb,
lib/tty/terminal/echo.rb,
lib/tty/terminal/home.rb,
lib/tty/terminal/pager.rb,
lib/tty/terminal/pager/basic.rb,
lib/tty/terminal/pager/system.rb

Defined Under Namespace

Classes: BasicPager, Echo, Home, Pager, SystemPager

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Terminal

Initialize a Terminal



22
23
24
25
26
27
# File 'lib/tty/terminal.rb', line 22

def initialize(options = {})
  @color = Pastel.new
  @echo  = TTY::Terminal::Echo.new
  @pager = TTY::Terminal::Pager
  @home  = Home.new
end

Instance Attribute Details

#colorTTY::Terminal::Color (readonly)

Return access to color terminal

Returns:

  • (TTY::Terminal::Color)


10
11
12
# File 'lib/tty/terminal.rb', line 10

def color
  @color
end

#pagerTTY::Terminal::Pager (readonly)

Output pager



17
18
19
# File 'lib/tty/terminal.rb', line 17

def pager
  @pager
end

Instance Method Details

#echo(is_on = true, &block) ⇒ Object

Echo given block

Parameters:

  • is_on (Boolean) (defaults to: true)


48
49
50
# File 'lib/tty/terminal.rb', line 48

def echo(is_on = true, &block)
  @echo.echo(is_on, &block)
end

#echo_offObject

Switch echo off



39
40
41
# File 'lib/tty/terminal.rb', line 39

def echo_off
  @echo.off
end

#echo_onObject

Switch echo on



32
33
34
# File 'lib/tty/terminal.rb', line 32

def echo_on
  @echo.on
end

#homeString

Find user home directory

Returns:

  • (String)


57
58
59
# File 'lib/tty/terminal.rb', line 57

def home
  @home.home
end

#page(text) ⇒ Object

Run text through a dynamically chosen pager

Parameters:

  • text (String)

    the text to page



67
68
69
# File 'lib/tty/terminal.rb', line 67

def page(text)
  @pager.page(text)
end