Class: OCG
- Inherits:
-
Object
- Object
- OCG
- Extended by:
- Forwardable
- Includes:
- Enumerable, Copyable
- Defined in:
- lib/ocg/main.rb,
lib/ocg/error.rb,
lib/ocg/options.rb,
lib/ocg/version.rb,
lib/ocg/copyable.rb,
lib/ocg/validation.rb,
lib/ocg/operator/or.rb,
lib/ocg/operator/and.rb,
lib/ocg/operator/mix.rb,
lib/ocg/operator/abstract.rb
Overview
Option combination generator. Copyright © 2019 AUTHORS, MIT License.
Direct Known Subclasses
Defined Under Namespace
Modules: Copyable, Operator, Validation Classes: BaseError, NotImplementedError, Options, ValidateError
Constant Summary collapse
- DELEGATORS =
Current delegators.
%i[reset next last started? finished? length].freeze
- VARIABLES_TO_COPY =
Current variables to copy.
%i[generator].freeze
- VERSION =
Option combination generator version.
"1.4.3".freeze
Class Method Summary collapse
-
.prepare_generator(generator_or_options) ⇒ Object
Prepares options generator using
generator_or_options
.
Instance Method Summary collapse
-
#and(generator_or_options = {}) ⇒ Object
Adds
generator_or_options
to current option combinations generator. -
#each(&_block) ⇒ Object
Processes each option combination.
-
#initialize(generator_or_options = {}) ⇒ OCG
constructor
Initializes options generator using
generator_or_options
. -
#mix(generator_or_options = {}) ⇒ Object
Mixes
generator_or_options
with current option combinations generator. -
#or(generator_or_options = {}) ⇒ Object
Mixes
generator_or_options
with current option combinations generator.
Methods included from Copyable
Constructor Details
#initialize(generator_or_options = {}) ⇒ OCG
Initializes options generator using generator_or_options
. generator_or_options
may be generator
object or options
. options
is a hash with values convertable to array.
28 29 30 |
# File 'lib/ocg/main.rb', line 28 def initialize( = {}) @generator = self.class.prepare_generator end |
Class Method Details
.prepare_generator(generator_or_options) ⇒ Object
Prepares options generator using generator_or_options
. generator_or_options
may be generator
object or options
. options
is a hash with values convertable to array.
35 36 37 38 39 |
# File 'lib/ocg/main.rb', line 35 def self.prepare_generator() return if .is_a? OCG Options.new end |
Instance Method Details
#and(generator_or_options = {}) ⇒ Object
Adds generator_or_options
to current option combinations generator.
42 43 44 |
# File 'lib/ocg/main.rb', line 42 def and( = {}) Operator::AND.new self, end |
#each(&_block) ⇒ Object
Processes each option combination.
57 58 59 60 61 62 63 64 |
# File 'lib/ocg/main.rb', line 57 def each(&_block) instance = dup instance.reset yield instance.next until instance.finished? nil end |