Class: Slither::Definition
- Inherits:
-
Object
- Object
- Slither::Definition
- Defined in:
- lib/slither/definition.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Definition
constructor
A new instance of Definition.
- #method_missing(method, *args, &block) ⇒ Object
- #section(name, options = {}) {|section| ... } ⇒ Object
- #template(name, options = {}) {|section| ... } ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Definition
Returns a new instance of Definition.
5 6 7 8 9 |
# File 'lib/slither/definition.rb', line 5 def initialize( = {}) @sections = [] @templates = {} @options = { :align => :right }.merge() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
29 30 31 |
# File 'lib/slither/definition.rb', line 29 def method_missing(method, *args, &block) section(method, *args, &block) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/slither/definition.rb', line 3 def @options end |
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
3 4 5 |
# File 'lib/slither/definition.rb', line 3 def sections @sections end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
3 4 5 |
# File 'lib/slither/definition.rb', line 3 def templates @templates end |
Instance Method Details
#section(name, options = {}) {|section| ... } ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/slither/definition.rb', line 11 def section(name, = {}, &block) raise( ArgumentError, "Reserved or duplicate section name: '#{name}'") if Section::RESERVED_NAMES.include?( name ) || (@sections.size > 0 && @sections.map{ |s| s.name }.include?( name )) section = Slither::Section.new(name, @options.merge()) section.definition = self yield(section) @sections << section section end |