Module: Toys::StandardMixins::Highline

Includes:
Mixin
Defined in:
lib/toys/standard_mixins/highline.rb

Overview

A mixin that provides access to the capabilities of the highline gem.

This mixin requires the highline gem, version 2.0 or later. It will attempt to install the gem if it is not available.

You may make these methods available to your tool by including the following directive in your tool definition:

include :highline

A HighLine object will then be available by calling the #highline method. For information on using this object, see the Highline documentation. Some of the most common HighLine methods, such as say, are also mixed into the tool and can be called directly.

You can configure the HighLine object by passing options to the include directive. For example:

include :highline, my_stdin, my_stdout

The arguments will be passed on to the HighLine constructor.

Whether the HighLine object uses color is inferred from its output stream and the environment, using the same rule as a terminal. See Utils::Terminal.infer_styled. You can override it by setting use_color on the HighLine object.

Constant Summary collapse

KEY =

Context key for the highline object.

Returns:

  • (Object)
::Toys::UniqueKey.new("Toys::StandardMixins::Highline::KEY")

Instance Method Summary collapse

Methods included from Mixin

create

Instance Method Details

#agree ⇒ Object



56
57
58
# File 'lib/toys/standard_mixins/highline.rb', line 56

def agree(...)
  self[::Toys::StandardMixins::Highline::KEY].agree(...)
end

#ask ⇒ Object

Calls HighLine#ask



63
64
65
# File 'lib/toys/standard_mixins/highline.rb', line 63

def ask(...)
  self[::Toys::StandardMixins::Highline::KEY].ask(...)
end

#choose ⇒ Object



70
71
72
# File 'lib/toys/standard_mixins/highline.rb', line 70

def choose(...)
  self[::Toys::StandardMixins::Highline::KEY].choose(...)
end

#color(*args) ⇒ Object



112
113
114
# File 'lib/toys/standard_mixins/highline.rb', line 112

def color(*args)
  self[::Toys::StandardMixins::Highline::KEY].color(*args)
end

#color_code(*args) ⇒ Object



119
120
121
# File 'lib/toys/standard_mixins/highline.rb', line 119

def color_code(*args)
  self[::Toys::StandardMixins::Highline::KEY].color_code(*args)
end

#highline ⇒ ::HighLine

A tool-wide HighLine instance

Returns:

  • (::HighLine)


49
50
51
# File 'lib/toys/standard_mixins/highline.rb', line 49

def highline
  self[::Toys::StandardMixins::Highline::KEY]
end

#indent ⇒ Object



91
92
93
# File 'lib/toys/standard_mixins/highline.rb', line 91

def indent(...)
  self[::Toys::StandardMixins::Highline::KEY].indent(...)
end

#list ⇒ Object



77
78
79
# File 'lib/toys/standard_mixins/highline.rb', line 77

def list(...)
  self[::Toys::StandardMixins::Highline::KEY].list(...)
end

#new_scope ⇒ Object



133
134
135
# File 'lib/toys/standard_mixins/highline.rb', line 133

def new_scope
  self[::Toys::StandardMixins::Highline::KEY].new_scope
end

#newline ⇒ Object



98
99
100
# File 'lib/toys/standard_mixins/highline.rb', line 98

def newline
  self[::Toys::StandardMixins::Highline::KEY].newline
end

#puts(*args) ⇒ Object



105
106
107
# File 'lib/toys/standard_mixins/highline.rb', line 105

def puts(*args)
  self[::Toys::StandardMixins::Highline::KEY].puts(*args)
end

#say ⇒ Object

Calls HighLine#say



84
85
86
# File 'lib/toys/standard_mixins/highline.rb', line 84

def say(...)
  self[::Toys::StandardMixins::Highline::KEY].say(...)
end

#uncolor(*args) ⇒ Object



126
127
128
# File 'lib/toys/standard_mixins/highline.rb', line 126

def uncolor(*args)
  self[::Toys::StandardMixins::Highline::KEY].uncolor(*args)
end