Class: PinballWizard::Feature
- Inherits:
-
Object
- Object
- PinballWizard::Feature
- Defined in:
- lib/pinball_wizard/feature.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #determine_state ⇒ Object
- #disable(message = 'No reason given.') ⇒ Object
- #disabled? ⇒ Boolean
-
#initialize(name, options = {}) ⇒ Feature
constructor
A new instance of Feature.
- #state ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Feature
Returns a new instance of Feature.
8 9 10 11 12 13 14 |
# File 'lib/pinball_wizard/feature.rb', line 8 def initialize(name, = {}) @name = name.to_s @options = @active = ensure_callable(.fetch(:active, false)) @options = Helpers::Hash.without(, :name, :active) @disabled = false end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
5 6 7 |
# File 'lib/pinball_wizard/feature.rb', line 5 def active @active end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
6 7 8 |
# File 'lib/pinball_wizard/feature.rb', line 6 def disabled @disabled end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/pinball_wizard/feature.rb', line 6 def @message end |
#name ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute name.
5 6 7 |
# File 'lib/pinball_wizard/feature.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/pinball_wizard/feature.rb', line 5 def @options end |
Instance Method Details
#active? ⇒ Boolean
18 19 20 |
# File 'lib/pinball_wizard/feature.rb', line 18 def active? active.call end |
#determine_state ⇒ Object
32 33 34 |
# File 'lib/pinball_wizard/feature.rb', line 32 def determine_state # noop: use defaults end |
#disable(message = 'No reason given.') ⇒ Object
27 28 29 30 |
# File 'lib/pinball_wizard/feature.rb', line 27 def disable( = 'No reason given.') @disabled = true @message = end |
#disabled? ⇒ Boolean
22 23 24 25 |
# File 'lib/pinball_wizard/feature.rb', line 22 def disabled? determine_state # Called here for Registry#disabled? disabled end |
#state ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/pinball_wizard/feature.rb', line 36 def state if disabled? "disabled: #{}" elsif active? 'active' else 'inactive' end end |