Class: Scout::PluginOption

Inherits:
Object
  • Object
show all
Defined in:
lib/es-scout/plugin_options.rb

Overview

a data structure of an individual plugin option

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#advancedObject (readonly)

Returns the value of attribute advanced.



8
9
10
# File 'lib/es-scout/plugin_options.rb', line 8

def advanced
  @advanced
end

#defaultObject (readonly)

Returns the value of attribute default.



8
9
10
# File 'lib/es-scout/plugin_options.rb', line 8

def default
  @default
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/es-scout/plugin_options.rb', line 8

def name
  @name
end

#notesObject (readonly)

Returns the value of attribute notes.



8
9
10
# File 'lib/es-scout/plugin_options.rb', line 8

def notes
  @notes
end

#passwordObject (readonly)

Returns the value of attribute password.



8
9
10
# File 'lib/es-scout/plugin_options.rb', line 8

def password
  @password
end

#requiredObject (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

Returns:

  • (Boolean)


20
# File 'lib/es-scout/plugin_options.rb', line 20

def advanced?; @advanced; end

#has_default?Boolean

Returns:

  • (Boolean)


23
# File 'lib/es-scout/plugin_options.rb', line 23

def has_default?; default != '';end

#password?Boolean

Returns:

  • (Boolean)


21
# File 'lib/es-scout/plugin_options.rb', line 21

def password?; @password; end

#required?Boolean

Returns:

  • (Boolean)


22
# File 'lib/es-scout/plugin_options.rb', line 22

def required?; @required; end

#to_sObject



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