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.



512
513
514
515
# File 'lib/vizcore/dsl/engine.rb', line 512

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



520
521
522
523
524
525
# File 'lib/vizcore/dsl/engine.rb', line 520

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)


549
550
551
552
553
554
555
556
# File 'lib/vizcore/dsl/engine.rb', line 549

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)


537
538
539
540
541
542
# File 'lib/vizcore/dsl/engine.rb', line 537

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



559
560
561
562
563
564
# File 'lib/vizcore/dsl/engine.rb', line 559

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



529
530
531
# File 'lib/vizcore/dsl/engine.rb', line 529

def trigger(&block)
  @trigger = block
end