Class: Vizcore::DSL::Engine::TransitionBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/vizcore/dsl/engine.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Builder object for ‘transition` block internals.

Instance Method Summary collapse

Constructor Details

#initializeTransitionBuilder

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 TransitionBuilder.



388
389
390
391
# File 'lib/vizcore/dsl/engine.rb', line 388

def initialize
  @effect = nil
  @trigger = nil
end

Instance Method Details

#effect(name, **options) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • name (Symbol, String)

    transition effect name

  • options (Hash)

    effect options



396
397
398
399
400
401
# File 'lib/vizcore/dsl/engine.rb', line 396

def effect(name, **options)
  @effect = {
    name: name.to_sym,
    options: options.each_with_object({}) { |(key, value), output| output[key.to_sym] = value }
  }
end

#on_bar(count, beats_per_bar: 4) ⇒ void

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.

This method returns an undefined value.

Trigger after a scene-local bar count reaches the given value.

Parameters:

  • count (Integer)
  • beats_per_bar (Integer) (defaults to: 4)

Raises:

  • (ArgumentError)


425
426
427
428
429
430
431
432
# File 'lib/vizcore/dsl/engine.rb', line 425

def on_bar(count, beats_per_bar: 4)
  bar_target = Integer(count)
  beats = Integer(beats_per_bar)
  raise ArgumentError, "on_bar count must be positive" unless bar_target.positive?
  raise ArgumentError, "beats_per_bar must be positive" unless beats.positive?

  on_beat(bar_target * beats)
end

#on_beat(count) ⇒ void

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.

This method returns an undefined value.

Trigger after a scene-local beat count reaches the given value.

Parameters:

  • count (Integer)

Raises:

  • (ArgumentError)


413
414
415
416
417
418
# File 'lib/vizcore/dsl/engine.rb', line 413

def on_beat(count)
  beat_target = Integer(count)
  raise ArgumentError, "on_beat count must be positive" unless beat_target.positive?

  @trigger = proc { beat_count >= beat_target }
end

#to_hHash

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 serialized transition extras.

Returns:

  • (Hash)

    serialized transition extras



435
436
437
438
439
440
# File 'lib/vizcore/dsl/engine.rb', line 435

def to_h
  output = {}
  output[:effect] = @effect if @effect
  output[:trigger] = @trigger if @trigger
  output
end

#trigger { ... } ⇒ void

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.

This method returns an undefined value.

Yields:

  • Trigger predicate executed in transition context



405
406
407
# File 'lib/vizcore/dsl/engine.rb', line 405

def trigger(&block)
  @trigger = block
end