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 configuration:

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.

Constant Summary collapse

KEY =

Context key for the highline object.

Returns:

  • (Object)
::Object.new.freeze

Instance Method Summary collapse

Instance Method Details

#agree(*args, &block) ⇒ Object

See Also:



87
88
89
# File 'lib/toys/standard_mixins/highline.rb', line 87

def agree(*args, &block)
  highline.agree(*args, &block)
end

#ask(*args, &block) ⇒ Object

See Also:



94
95
96
# File 'lib/toys/standard_mixins/highline.rb', line 94

def ask(*args, &block)
  highline.ask(*args, &block)
end

#choose(*args, &block) ⇒ Object

See Also:



101
102
103
# File 'lib/toys/standard_mixins/highline.rb', line 101

def choose(*args, &block)
  highline.choose(*args, &block)
end

#color(*args) ⇒ Object

See Also:



143
144
145
# File 'lib/toys/standard_mixins/highline.rb', line 143

def color(*args)
  highline.color(*args)
end

#color_code(*args) ⇒ Object



150
151
152
# File 'lib/toys/standard_mixins/highline.rb', line 150

def color_code(*args)
  highline.color_code(*args)
end

#highline::HighLine

Returns a tool-wide highline instance

Returns:

  • (::HighLine)


80
81
82
# File 'lib/toys/standard_mixins/highline.rb', line 80

def highline
  self[KEY]
end

#indent(*args, &block) ⇒ Object

See Also:



122
123
124
# File 'lib/toys/standard_mixins/highline.rb', line 122

def indent(*args, &block)
  highline.indent(*args, &block)
end

#list(*args, &block) ⇒ Object

See Also:



108
109
110
# File 'lib/toys/standard_mixins/highline.rb', line 108

def list(*args, &block)
  highline.list(*args, &block)
end

#new_scopeObject

See Also:



164
165
166
# File 'lib/toys/standard_mixins/highline.rb', line 164

def new_scope
  highline.new_scope
end

#newlineObject

See Also:



129
130
131
# File 'lib/toys/standard_mixins/highline.rb', line 129

def newline
  highline.newline
end

#puts(*args) ⇒ Object

See Also:



136
137
138
# File 'lib/toys/standard_mixins/highline.rb', line 136

def puts(*args)
  highline.puts(*args)
end

#say(*args, &block) ⇒ Object

See Also:



115
116
117
# File 'lib/toys/standard_mixins/highline.rb', line 115

def say(*args, &block)
  highline.say(*args, &block)
end

#uncolor(*args) ⇒ Object

See Also:



157
158
159
# File 'lib/toys/standard_mixins/highline.rb', line 157

def uncolor(*args)
  highline.uncolor(*args)
end