Class: Diggit::Plugin Abstract
- Inherits:
-
Object
- Object
- Diggit::Plugin
- Defined in:
- lib/dgit/plugins.rb
Overview
This class is abstract.
Abstract superclass for all plugins.
Base class for plugins. They have associated options.
Instance Attribute Summary collapse
-
#options ⇒ Hash<String, Object>
readonly
The hash of options.
Class Method Summary collapse
-
.name ⇒ String
Returns the name of the plugin class.
Instance Method Summary collapse
-
#initialize(options) ⇒ Plugin
constructor
A new instance of Plugin.
-
#name ⇒ String
Returns the name of the plugin class.
-
#read_option(ns, opt, default) ⇒ Object
Returns the value of a plugin option.
Constructor Details
#initialize(options) ⇒ Plugin
Returns a new instance of Plugin.
29 30 31 |
# File 'lib/dgit/plugins.rb', line 29 def initialize() @options = end |
Instance Attribute Details
#options ⇒ Hash<String, Object> (readonly)
Returns the hash of options.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dgit/plugins.rb', line 26 class Plugin attr_reader :options def initialize() @options = end # Returns the name of the plugin class # @return [String] def name self.class.name end # Returns the name of the plugin class # @return [String] def self.name to_s.underscore end # Returns the value of a plugin option # @param ns [Symbol] the name of the option's namespace # @param opt [Symbol] the name of the option # @param default [Object] the default value # @return [Object] def read_option(ns, opt, default) return @options[ns][opt] if @options.key?(ns) && @options[ns].key?(opt) default end end |
Class Method Details
.name ⇒ String
Returns the name of the plugin class
41 42 43 |
# File 'lib/dgit/plugins.rb', line 41 def self.name to_s.underscore end |
Instance Method Details
#name ⇒ String
Returns the name of the plugin class
35 36 37 |
# File 'lib/dgit/plugins.rb', line 35 def name self.class.name end |
#read_option(ns, opt, default) ⇒ Object
Returns the value of a plugin option
50 51 52 53 |
# File 'lib/dgit/plugins.rb', line 50 def read_option(ns, opt, default) return @options[ns][opt] if @options.key?(ns) && @options[ns].key?(opt) default end |