Class: U3dCore::Interface
- Inherits:
-
Object
- Object
- U3dCore::Interface
- Defined in:
- lib/u3d_core/ui/interface.rb
Overview
Abstract super class
Direct Known Subclasses
Defined Under Namespace
Messaging: show text to the user collapse
-
#command(_message) ⇒ Object
Level Command: Print out a terminal command that is being executed.
-
#command_output(_message) ⇒ Object
Level Command Output: Print the output of a command with this method.
-
#deprecated(_message) ⇒ Object
Level Deprecated: Show that a particular function is deprecated.
-
#error(_message) ⇒ Object
Level Error: Can be used to show additional error information before actually raising an exception or can be used to just show an error from which u3d can recover (much magic).
-
#header(_message) ⇒ Object
Print a header = a text in a box use this if this message is really important.
-
#important(_message) ⇒ Object
Level Important: Can be used to show warnings to the user not necessarly negative, but something the user should be aware of.
-
#message(_message) ⇒ Object
Level Message: Show a neutral message to the user.
-
#success(_message) ⇒ Object
Level Success: Show that something was successful.
-
#verbose(_message) ⇒ Object
Level Verbose: Print out additional information for the users that are interested.
Errors: Inputs collapse
-
#confirm(_message) ⇒ Object
A simple yes or no question.
-
#input(_message) ⇒ Object
get a standard text input (single line).
-
#interactive?(_message) ⇒ Boolean
Is is possible to ask the user questions?.
-
#password(_message) ⇒ Object
Password input for the user, text field shouldn’t show plain text.
-
#select(_message, _options) ⇒ Object
Let the user select one out of x items return value is the value of the option the user chose.
Errors: Different kinds of exceptions collapse
-
#crash!(exception) ⇒ Object
Pass an exception to this method to exit the program using the given exception Use this method instead of user_error! if this error is unexpected, e.g.
-
#user_error!(error_message, options = {}) ⇒ Object
Use this method to exit the program because of an user error e.g.
Helpers collapse
Instance Method Details
#command(_message) ⇒ Object
Level Command: Print out a terminal command that is being
executed.
By default those messages shown in cyan
75 76 77 |
# File 'lib/u3d_core/ui/interface.rb', line 75 def command() not_implemented(__method__) end |
#command_output(_message) ⇒ Object
Level Command Output: Print the output of a command with
this method
By default those messages shown in magenta
83 84 85 |
# File 'lib/u3d_core/ui/interface.rb', line 83 def command_output() not_implemented(__method__) end |
#confirm(_message) ⇒ Object
A simple yes or no question
117 118 119 |
# File 'lib/u3d_core/ui/interface.rb', line 117 def confirm() not_implemented(__method__) end |
#crash!(exception) ⇒ Object
Pass an exception to this method to exit the program
using the given exception
Use this method instead of user_error! if this error is unexpected, e.g. an invalid server response that shouldn’t happen
154 155 156 |
# File 'lib/u3d_core/ui/interface.rb', line 154 def crash!(exception) raise UICrash.new, exception.to_s end |
#deprecated(_message) ⇒ Object
Level Deprecated: Show that a particular function is deprecated
By default those messages shown in strong blue
67 68 69 |
# File 'lib/u3d_core/ui/interface.rb', line 67 def deprecated() not_implemented(__method__) end |
#error(_message) ⇒ Object
Level Error: Can be used to show additional error
information before actually raising an exception
or can be used to just show an error from which
u3d can recover (much magic)
By default those messages are shown in red
37 38 39 |
# File 'lib/u3d_core/ui/interface.rb', line 37 def error() not_implemented(__method__) end |
#header(_message) ⇒ Object
Print a header = a text in a box
use this if this is really important
98 99 100 |
# File 'lib/u3d_core/ui/interface.rb', line 98 def header() not_implemented(__method__) end |
#important(_message) ⇒ Object
Level Important: Can be used to show warnings to the user
not necessarly negative, but something the user should
be aware of.
By default those messages are shown in yellow
46 47 48 |
# File 'lib/u3d_core/ui/interface.rb', line 46 def important() not_implemented(__method__) end |
#input(_message) ⇒ Object
get a standard text input (single line)
112 113 114 |
# File 'lib/u3d_core/ui/interface.rb', line 112 def input() not_implemented(__method__) end |
#interactive?(_message) ⇒ Boolean
Is is possible to ask the user questions?
107 108 109 |
# File 'lib/u3d_core/ui/interface.rb', line 107 def interactive?() not_implemented(__method__) end |
#message(_message) ⇒ Object
Level Message: Show a neutral message to the user
By default those messages shown in white/black
60 61 62 |
# File 'lib/u3d_core/ui/interface.rb', line 60 def () not_implemented(__method__) end |
#not_implemented(method_name) ⇒ Object
174 175 176 |
# File 'lib/u3d_core/ui/interface.rb', line 174 def not_implemented(method_name) UI.user_error!("Current UI '#{self}' doesn't support method '#{method_name}'") end |
#password(_message) ⇒ Object
Password input for the user, text field shouldn’t show plain text
129 130 131 |
# File 'lib/u3d_core/ui/interface.rb', line 129 def password() not_implemented(__method__) end |
#select(_message, _options) ⇒ Object
Let the user select one out of x items return value is the value of the option the user chose
123 124 125 |
# File 'lib/u3d_core/ui/interface.rb', line 123 def select(, ) not_implemented(__method__) end |
#success(_message) ⇒ Object
Level Success: Show that something was successful
By default those messages are shown in green
53 54 55 |
# File 'lib/u3d_core/ui/interface.rb', line 53 def success() not_implemented(__method__) end |
#to_s ⇒ Object
178 179 180 |
# File 'lib/u3d_core/ui/interface.rb', line 178 def to_s self.class.name.split('::').last end |
#user_error!(error_message, options = {}) ⇒ Object
Use this method to exit the program because of an user error
e.g. app doesn't exist on the given Developer Account
or invalid user credentials
or scan tests fail
This will show the error message, but doesn’t show the full
stack trace
Basically this should be used when you actively catch the error and want to show a nice error message to the user
166 167 168 169 |
# File 'lib/u3d_core/ui/interface.rb', line 166 def user_error!(, = {}) = { show_github_issues: false }.merge() raise UIError.new(show_github_issues: [:show_github_issues]), .to_s end |
#verbose(_message) ⇒ Object
Level Verbose: Print out additional information for the
users that are interested. Will only be printed when
$verbose = true
By default those messages are shown in white
92 93 94 |
# File 'lib/u3d_core/ui/interface.rb', line 92 def verbose() not_implemented(__method__) end |