Class: ConfCtl::ModuleOptions::Option
- Inherits:
-
Object
- Object
- ConfCtl::ModuleOptions::Option
- Defined in:
- lib/confctl/module_options.rb
Instance Attribute Summary collapse
-
#declarations ⇒ Object
readonly
Returns the value of attribute declarations.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#example ⇒ Object
readonly
Returns the value of attribute example.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(nixos_opt) ⇒ Option
constructor
A new instance of Option.
- #md_description ⇒ Object
- #nix_default ⇒ Object
- #nix_example ⇒ Object
Constructor Details
#initialize(nixos_opt) ⇒ Option
Returns a new instance of Option.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/confctl/module_options.rb', line 8 def initialize(nixos_opt) @name = nixos_opt['name'] @description = nixos_opt['description'] || 'This option has no description.' @type = nixos_opt['type'] @default = extract_expression(nixos_opt['default']) @example = extract_expression(nixos_opt['example']) @declarations = nixos_opt['declarations'].map do |v| raise "unable to place module '#{v}'" unless %r{/confctl/([^$]+)} =~ v "<confctl/#{::Regexp.last_match(1)}>" end end |
Instance Attribute Details
#declarations ⇒ Object (readonly)
Returns the value of attribute declarations.
6 7 8 |
# File 'lib/confctl/module_options.rb', line 6 def declarations @declarations end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
6 7 8 |
# File 'lib/confctl/module_options.rb', line 6 def default @default end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/confctl/module_options.rb', line 6 def description @description end |
#example ⇒ Object (readonly)
Returns the value of attribute example.
6 7 8 |
# File 'lib/confctl/module_options.rb', line 6 def example @example end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/confctl/module_options.rb', line 6 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/confctl/module_options.rb', line 6 def type @type end |
Instance Method Details
#md_description ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/confctl/module_options.rb', line 21 def md_description tagless = description .gsub(%r{<literal>([^<]+)</literal>}, '`\1`') .gsub(%r{<option>([^<]+)</option>}, '`\1`') CGI.unescapeHTML(tagless) end |
#nix_default ⇒ Object
29 30 31 |
# File 'lib/confctl/module_options.rb', line 29 def nix_default nixify(default) end |
#nix_example ⇒ Object
33 34 35 |
# File 'lib/confctl/module_options.rb', line 33 def nix_example example && nixify(example) end |