Module: Gem::DefaultUserInteraction
- Includes:
- 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 Method Summary collapse
-
.ui ⇒ Object
Return the default UI.
-
.ui=(new_ui) ⇒ Object
Set the default UI.
-
.use_ui(new_ui) ⇒ Object
Use
new_ui
for the duration ofblock
.
Instance Method Summary collapse
-
#ui ⇒ Object
See DefaultUserInteraction::ui.
-
#ui=(new_ui) ⇒ Object
See DefaultUserInteraction::ui=.
-
#use_ui(new_ui, &block) ⇒ Object
See DefaultUserInteraction::use_ui.
Methods included from Text
#clean_text, #format_text, #levenshtein_distance, #min3, #truncate_text
Class Method Details
.ui ⇒ Object
Return the default UI.
28 29 30 |
# File 'lib/rubygems/user_interaction.rb', line 28 def self.ui @ui ||= Gem::ConsoleUI.new end |
.ui=(new_ui) ⇒ Object
Set the default UI. If the default UI is never explicitly set, a simple console based UserInteraction will be used automatically.
36 37 38 |
# File 'lib/rubygems/user_interaction.rb', line 36 def self.ui=(new_ui) @ui = new_ui end |
.use_ui(new_ui) ⇒ Object
Use new_ui
for the duration of block
.
43 44 45 46 47 48 49 |
# File 'lib/rubygems/user_interaction.rb', line 43 def self.use_ui(new_ui) old_ui = @ui @ui = new_ui yield ensure @ui = old_ui end |
Instance Method Details
#ui ⇒ Object
See DefaultUserInteraction::ui
54 55 56 |
# File 'lib/rubygems/user_interaction.rb', line 54 def ui Gem::DefaultUserInteraction.ui end |
#ui=(new_ui) ⇒ Object
See DefaultUserInteraction::ui=
61 62 63 |
# File 'lib/rubygems/user_interaction.rb', line 61 def ui=(new_ui) Gem::DefaultUserInteraction.ui = new_ui end |
#use_ui(new_ui, &block) ⇒ Object
See DefaultUserInteraction::use_ui
68 69 70 |
# File 'lib/rubygems/user_interaction.rb', line 68 def use_ui(new_ui, &block) Gem::DefaultUserInteraction.use_ui(new_ui, &block) end |