Class: Yacl::Simple
- Inherits:
-
Define::Cli::Runner
- Object
- Define::Cli::Runner
- Yacl::Simple
- Defined in:
- lib/yacl/simple.rb
Class Method Summary collapse
-
.defaults(&block) ⇒ Object
Public: Create a child class of Yacl::Define::Defaults.
-
.nested_class(name, parent, &block) ⇒ Object
Internal: Define a class that is a nested class of the module.
-
.parser(&block) ⇒ Object
Public: Creates a child class of Yacl::Define::Cli::Parser.
-
.plan(&block) ⇒ Object
Public: Creates a child class of Yacl::Define::Plan.
Methods inherited from Define::Cli::Runner
go, #initialize, #plan_klass, #properties
Constructor Details
This class inherits a constructor from Yacl::Define::Cli::Runner
Class Method Details
.defaults(&block) ⇒ Object
Public: Create a child class of Yacl::Define::Defaults
block - an optional block will be evaluated in the context of the
created class.
The child class is created once, and the block is evaluated once. Further class to this method will result in returning the already defined class.
12 13 14 |
# File 'lib/yacl/simple.rb', line 12 def defaults( &block ) nested_class( 'Defaults', Yacl::Define::Defaults, &block ) end |
.nested_class(name, parent, &block) ⇒ Object
Internal: Define a class that is a nested class of the module
41 42 43 44 45 46 47 48 |
# File 'lib/yacl/simple.rb', line 41 def nested_class( name, parent, &block ) unless const_defined?( name ) then klass = Class.new( parent ) klass.class_eval( &block ) if block_given? const_set( name , klass ) end return const_get( name ) end |
.parser(&block) ⇒ Object
Public: Creates a child class of Yacl::Define::Cli::Parser
block - an optional block will be evaluated in the context of the
created class.
The child class is created once, and the block is evaluated once. Further class to this method will result in returning the already defined class.
24 25 26 |
# File 'lib/yacl/simple.rb', line 24 def parser( &block ) nested_class( 'Parser', Yacl::Define::Cli::Parser, &block ) end |
.plan(&block) ⇒ Object
Public: Creates a child class of Yacl::Define::Plan
block - an optional block will be evaluated in the context of the
created class.
The child class is created once, and the block is evaluated once. Further class to this method will result in returning the already defined class.
36 37 38 |
# File 'lib/yacl/simple.rb', line 36 def plan( &block ) nested_class( 'Plan', Yacl::Define::Plan, &block ) end |