123456789_123456789_123456789_123456789_123456789_

Module: Gem::DefaultUserInteraction

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Extended In:
Included In:
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Text
Defined in: lib/rubygems/user_interaction.rb

Overview

Module that defines the default UserInteraction. Any class including this module will have access to the .ui method that returns the default UI.

Class Attribute Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Text - Included

#clean_text

Remove any non-printable characters and make the text suitable for printing.

#format_text

Wraps text to wrap characters and optionally indents by indent characters.

#levenshtein_distance

Returns a value representing the “cost” of transforming str1 into str2 Vendored version of DidYouMean::Levenshtein.distance from the ruby/did_you_mean gem @ 1.4.0 github.com/ruby/did_you_mean/blob/2ddf39b874808685965dbc47d344cf6c7651807c/lib/did_you_mean/levenshtein.rb#L7-L37.

#truncate_text, #min3

Class Attribute Details

.ui (rw)

Return the default UI.

[ GitHub ]

  
# File 'lib/rubygems/user_interaction.rb', line 29

def self.ui
  @ui ||= Gem::ConsoleUI.new
end

.ui=(new_ui) (rw)

Set the default UI. If the default UI is never explicitly set, a simple console based UserInteraction will be used automatically.

[ GitHub ]

  
# File 'lib/rubygems/user_interaction.rb', line 37

def self.ui=(new_ui)
  @ui = new_ui
end

Class Method Details

.use_ui(new_ui)

Use new_ui for the duration of block.

[ GitHub ]

  
# File 'lib/rubygems/user_interaction.rb', line 44

def self.use_ui(new_ui)
  old_ui = @ui
  @ui = new_ui
  yield
ensure
  @ui = old_ui
end

Instance Attribute Details

#ui (rw)

See .ui

[ GitHub ]

  
# File 'lib/rubygems/user_interaction.rb', line 55

def ui
  Gem::DefaultUserInteraction.ui
end

#ui=(new_ui) (rw)

See .ui=

[ GitHub ]

  
# File 'lib/rubygems/user_interaction.rb', line 62

def ui=(new_ui)
  Gem::DefaultUserInteraction.ui = new_ui
end

Instance Method Details

#use_ui(new_ui, &block)

See .use_ui

[ GitHub ]

  
# File 'lib/rubygems/user_interaction.rb', line 69

def use_ui(new_ui, &block)
  Gem::DefaultUserInteraction.use_ui(new_ui, &block)
end