Class: Scout::PluginOption
- Inherits:
-
Object
- Object
- Scout::PluginOption
- Defined in:
- lib/es-scout/plugin_options.rb
Overview
a data structure of an individual plugin option
Instance Attribute Summary collapse
-
#advanced ⇒ Object
readonly
Returns the value of attribute advanced.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
Instance Method Summary collapse
-
#advanced? ⇒ Boolean
convenience – for nicer syntax.
- #has_default? ⇒ Boolean
-
#initialize(name, h) ⇒ PluginOption
constructor
A new instance of PluginOption.
- #password? ⇒ Boolean
- #required? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name, h) ⇒ PluginOption
Returns a new instance of PluginOption.
9 10 11 12 13 14 15 16 17 |
# File 'lib/es-scout/plugin_options.rb', line 9 def initialize(name, h) @name=name @notes=h['notes'] || '' @default=h['default'] || '' @attributes=h['attributes'] || '' @advanced = @attributes.include?('advanced') @password = @attributes.include?('password') @required = @attributes.include?('required') end |
Instance Attribute Details
#advanced ⇒ Object (readonly)
Returns the value of attribute advanced.
8 9 10 |
# File 'lib/es-scout/plugin_options.rb', line 8 def advanced @advanced end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
8 9 10 |
# File 'lib/es-scout/plugin_options.rb', line 8 def default @default end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/es-scout/plugin_options.rb', line 8 def name @name end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
8 9 10 |
# File 'lib/es-scout/plugin_options.rb', line 8 def notes @notes end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
8 9 10 |
# File 'lib/es-scout/plugin_options.rb', line 8 def password @password end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
8 9 10 |
# File 'lib/es-scout/plugin_options.rb', line 8 def required @required end |
Instance Method Details
#advanced? ⇒ Boolean
convenience – for nicer syntax
20 |
# File 'lib/es-scout/plugin_options.rb', line 20 def advanced?; @advanced; end |
#has_default? ⇒ Boolean
23 |
# File 'lib/es-scout/plugin_options.rb', line 23 def has_default?; default != '';end |
#password? ⇒ Boolean
21 |
# File 'lib/es-scout/plugin_options.rb', line 21 def password?; @password; end |
#required? ⇒ Boolean
22 |
# File 'lib/es-scout/plugin_options.rb', line 22 def required?; @required; end |
#to_s ⇒ Object
25 26 27 28 29 |
# File 'lib/es-scout/plugin_options.rb', line 25 def to_s required_string = required? ? " (required). " : "" default_string = default == '' ? '' : " Default: #{default}. " "'#{name}'#{required_string}#{default_string}#{notes}" end |