Class: Ablerc::Option
- Inherits:
-
Hashie::Dash
- Object
- Hashie::Dash
- Ablerc::Option
- Defined in:
- lib/ablerc/option.rb
Overview
An option is a declared attribute within an rc file, in other words, an uncommented key-value pair.
Options define how an attribute behaves (via behavior parameters), which are used to validate, explain and control default values for the option.
Instance Attribute Summary collapse
-
#allows ⇒ Object
Returns the value of attribute allows.
-
#boolean ⇒ Object
Returns the value of attribute boolean.
-
#default ⇒ Object
Returns the value of attribute default.
-
#description ⇒ Object
Returns the value of attribute description.
-
#disabled ⇒ Object
Returns the value of attribute disabled.
-
#refuses ⇒ Object
Returns the value of attribute refuses.
Instance Method Summary collapse
-
#initialize(name, behaviors = {}, &block) ⇒ Option
constructor
Initialize the option.
- #to_stub ⇒ Object
Constructor Details
#initialize(name, behaviors = {}, &block) ⇒ Option
Initialize the option
Parameters
-
name
- A valid name for the option -
behaviors
- Behaviors used to for this option -
block
- A proc that should be run against the option value.
Options
-
allow
- The option value must be in this list -
boolean
- The option will accepttrue
,false
,0
,1
26 27 28 29 |
# File 'lib/ablerc/option.rb', line 26 def initialize(name, behaviors = {}, &block) self.name = name extract_behaviors( behaviors ) end |
Instance Attribute Details
#allows ⇒ Object
Returns the value of attribute allows.
15 16 17 |
# File 'lib/ablerc/option.rb', line 15 def allows @allows end |
#boolean ⇒ Object
Returns the value of attribute boolean.
15 16 17 |
# File 'lib/ablerc/option.rb', line 15 def boolean @boolean end |
#default ⇒ Object
Returns the value of attribute default.
15 16 17 |
# File 'lib/ablerc/option.rb', line 15 def default @default end |
#description ⇒ Object
Returns the value of attribute description.
15 16 17 |
# File 'lib/ablerc/option.rb', line 15 def description @description end |
#disabled ⇒ Object
Returns the value of attribute disabled.
15 16 17 |
# File 'lib/ablerc/option.rb', line 15 def disabled @disabled end |
#refuses ⇒ Object
Returns the value of attribute refuses.
15 16 17 |
# File 'lib/ablerc/option.rb', line 15 def refuses @refuses end |
Instance Method Details
#to_stub ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/ablerc/option.rb', line 32 def to_stub stub = "## #{name}\n" stub << "# #{description}\n" unless description.nil? stub << "#{entry_for_refuse_allow_behavior}\n" unless refuses.nil? and allows.nil? stub << "#{entry_for_key_value}\n" stub << "\n" end |