Class: Scout::PluginOptions
- Inherits:
-
Array
- Object
- Array
- Scout::PluginOptions
- Defined in:
- lib/es-scout/plugin_options.rb
Overview
A collection of pluginOption Create: opts=PluginOptions.from_yaml(yaml_string) Check if there were any problems – opts.error – should be nil.
A valid options yaml looks like this:
max_swap_used:
notes: If swap is larger than this amount, an alert is generated. Amount should be in MB.
default: 2048 # 2 GB
max_swap_ratio:
notes: If swap used over memory used is larger than this amount, an alert is generated
default: 3
attributes: required advanced
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
Class Method Summary collapse
-
.from_yaml(string) ⇒ Object
Should be valid YAML, a hash of hashes …
Instance Method Summary collapse
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
46 47 48 |
# File 'lib/es-scout/plugin_options.rb', line 46 def error @error end |
Class Method Details
.from_yaml(string) ⇒ Object
Should be valid YAML, a hash of hashes … if not, will be caught in the rescue below
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/es-scout/plugin_options.rb', line 49 def self.from_yaml(string) =[] error=nil items=YAML.load(string) items.each_pair {|name, hash| .push(PluginOption.new(name,hash)) } rescue error="Invalid Plugin Options" ensure res=PluginOptions.new() res.error=error return res end |
Instance Method Details
#advanced ⇒ Object
63 64 65 |
# File 'lib/es-scout/plugin_options.rb', line 63 def advanced select{|o|o.advanced? } end |
#regular ⇒ Object
67 68 69 |
# File 'lib/es-scout/plugin_options.rb', line 67 def regular select{|o|!o.advanced? } end |
#to_s ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/es-scout/plugin_options.rb', line 71 def to_s res=[] each_with_index do |opt,i| res.push "#{i+1}. #{opt.to_s}" end res.join("\n") end |