Class: Quick::Sampler::DSL
- Inherits:
-
Object
- Object
- Quick::Sampler::DSL
- Includes:
- Config, SimpleCombinators, SimpleValues
- Defined in:
- lib/quick/sampler/dsl.rb
Overview
A domain specific method for sampler definitions.
Instance methods of this class are available as barewords inside a sampler definition supplied as a block to compile.
Methods that produce a sampler actually wrap it in a Fluidiom instance that adds a fluid API to the sampler. This wrapping is stripped off from the sampler returned by compile - although I'm still undesided if that's the right thing to do.
(Incidentally, Fluidiom instances for deeper nested sub-samplers get leaked from compile at the moment)
Defined Under Namespace
Modules: SimpleCombinators, SimpleValues Classes: Fluidiom
Class Method Summary collapse
-
.compile(description: nil, &block) ⇒ Object
private
(see Quick::Sampler.compile).
Instance Method Summary collapse
-
#feed(&block) ⇒ Object
Wraps a block into a lazy enumerator which will become sampler.
-
#initialize(binding = nil) ⇒ DSL
constructor
private
A new instance of DSL.
-
#inspect ⇒ Object
overloaded to display human readable text in tests output.
Methods included from SimpleCombinators
#list_like, #list_of, #one_of, #one_of_weighted, #pick_from, #send_to, #vector_of
Methods included from SimpleValues
#boolean, #const, #fixnum, #integer, #negative_fixnum, #positive_fixnum, #string, #zero
Methods included from Config
Constructor Details
#initialize(binding = nil) ⇒ DSL
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DSL.
22 23 24 |
# File 'lib/quick/sampler/dsl.rb', line 22 def initialize binding = nil setup_delegation(binding) if binding end |
Class Method Details
.compile(description: nil, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
(see Quick::Sampler.compile)
28 29 30 31 32 |
# File 'lib/quick/sampler/dsl.rb', line 28 def self.compile description: nil, &block new(block.binding).instance_eval(&block).unwrap.tap do |sampler| sampler.description = description end end |
Instance Method Details
#feed(&block) ⇒ Object
Wraps a block into a lazy enumerator which will become sampler.
I haven't decided yet if this is a private implementation detail or a powerful albeit confusing DSL verb
46 47 48 |
# File 'lib/quick/sampler/dsl.rb', line 46 def feed &block Fluidiom.new(Base.new(block), config) end |
#inspect ⇒ Object
overloaded to display human readable text in tests output
35 36 37 |
# File 'lib/quick/sampler/dsl.rb', line 35 def inspect "Quick Sampler DSL" end |