Class: Scout::PluginOption

Inherits:
Object
  • Object
show all
Defined in:
lib/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
18
# File 'lib/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')
  @hash = h
end

Instance Attribute Details

#advancedObject (readonly)

Returns the value of attribute advanced.



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

def advanced
  @advanced
end

#defaultObject (readonly)

Returns the value of attribute default.



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

def default
  @default
end

#hashObject (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#notesObject (readonly)

Returns the value of attribute notes.



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

def notes
  @notes
end

#passwordObject (readonly)

Returns the value of attribute password.



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

def password
  @password
end

#requiredObject (readonly)

Returns the value of attribute required.



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

def required
  @required
end

Instance Method Details

#advanced?Boolean

convenience – for nicer syntax

Returns:

  • (Boolean)


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

def advanced?; @advanced; end

#has_default?Boolean

Returns:

  • (Boolean)


24
# File 'lib/scout/plugin_options.rb', line 24

def has_default?; default != '';end

#password?Boolean

Returns:

  • (Boolean)


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

def password?; @password; end

#required?Boolean

Returns:

  • (Boolean)


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

def required?; @required; end

#to_hashObject



32
33
34
# File 'lib/scout/plugin_options.rb', line 32

def to_hash
  @hash
end

#to_sObject



26
27
28
29
30
# File 'lib/scout/plugin_options.rb', line 26

def to_s
  required_string = required? ? " (required). " : ""
  default_string = default == '' ? '' : " Default: #{default}. " 
  "'#{name}'#{required_string}#{default_string}#{notes}"
end