Class: TTY::Plugin
- Inherits:
-
Object
- Object
- TTY::Plugin
- Defined in:
- lib/tty/plugins/plugin.rb
Overview
A class responsible for plugin loading
Instance Attribute Summary collapse
-
#gem ⇒ Object
readonly
Returns the value of attribute gem.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#enabled? ⇒ Boolean
Check if this plugin has been enabled.
-
#initialize(name, gem) ⇒ Plugin
constructor
Initialize a Plugin.
-
#load! ⇒ Object
Load the plugin (require the gem).
Constructor Details
#initialize(name, gem) ⇒ Plugin
Initialize a Plugin
19 20 21 22 23 |
# File 'lib/tty/plugins/plugin.rb', line 19 def initialize(name, gem) @name = name @gem = gem @enabled = false end |
Instance Attribute Details
#gem ⇒ Object (readonly)
Returns the value of attribute gem.
8 9 10 |
# File 'lib/tty/plugins/plugin.rb', line 8 def gem @gem end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/tty/plugins/plugin.rb', line 6 def name @name end |
Instance Method Details
#enabled? ⇒ Boolean
Check if this plugin has been enabled
30 31 32 |
# File 'lib/tty/plugins/plugin.rb', line 30 def enabled? @enabled end |
#load! ⇒ Object
Load the plugin (require the gem)
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tty/plugins/plugin.rb', line 37 def load! begin require name unless enabled? rescue LoadError => error puts("Unable to load plugin #{name} due to #{error}.") rescue => error puts("require '#{name}' failed with #{error}") end @enabled = true end |