Class: Plushie::Animation::Tween::State

Inherits:
Data
  • Object
show all
Includes:
Model::Extensions
Defined in:
lib/plushie/animation/tween.rb

Overview

Immutable animation state.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, to:, duration:, started_at: nil, easing: :linear, value: nil, repeat: nil, auto_reverse: false) ⇒ State

Returns a new instance of State.



49
50
51
52
53
# File 'lib/plushie/animation/tween.rb', line 49

def initialize(from:, to:, duration:, started_at: nil, easing: :linear,
  value: nil, repeat: nil, auto_reverse: false)
  super(from: from, to: to, duration: duration, started_at: started_at,
        easing: easing, value: value.nil? ? from : value, repeat: repeat, auto_reverse: auto_reverse)
end

Instance Attribute Details

#auto_reverseObject (readonly)

Returns the value of attribute auto_reverse

Returns:

  • (Object)

    the current value of auto_reverse



45
46
47
# File 'lib/plushie/animation/tween.rb', line 45

def auto_reverse
  @auto_reverse
end

#auto_reverse [Boolean] swap from/to on each cycle([Boolean]) ⇒ Object (readonly)

Immutable animation state.



45
46
47
48
49
50
51
52
53
54
# File 'lib/plushie/animation/tween.rb', line 45

State = ::Data.define(:from, :to, :duration, :started_at, :easing, :value,
  :repeat, :auto_reverse) do
  include Plushie::Model::Extensions

  def initialize(from:, to:, duration:, started_at: nil, easing: :linear,
    value: nil, repeat: nil, auto_reverse: false)
    super(from: from, to: to, duration: duration, started_at: started_at,
          easing: easing, value: value.nil? ? from : value, repeat: repeat, auto_reverse: auto_reverse)
  end
end

#durationObject (readonly)

Returns the value of attribute duration

Returns:

  • (Object)

    the current value of duration



45
46
47
# File 'lib/plushie/animation/tween.rb', line 45

def duration
  @duration
end

#easingObject (readonly)

Returns the value of attribute easing

Returns:

  • (Object)

    the current value of easing



45
46
47
# File 'lib/plushie/animation/tween.rb', line 45

def easing
  @easing
end

#fromObject (readonly)

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



45
46
47
# File 'lib/plushie/animation/tween.rb', line 45

def from
  @from
end

#repeatObject (readonly)

Returns the value of attribute repeat

Returns:

  • (Object)

    the current value of repeat



45
46
47
# File 'lib/plushie/animation/tween.rb', line 45

def repeat
  @repeat
end

#repeat [Integer, :forever, nil] remaining repeat count([Integer,: forever, nil]) ⇒ Object (readonly)

Immutable animation state.



45
46
47
48
49
50
51
52
53
54
# File 'lib/plushie/animation/tween.rb', line 45

State = ::Data.define(:from, :to, :duration, :started_at, :easing, :value,
  :repeat, :auto_reverse) do
  include Plushie::Model::Extensions

  def initialize(from:, to:, duration:, started_at: nil, easing: :linear,
    value: nil, repeat: nil, auto_reverse: false)
    super(from: from, to: to, duration: duration, started_at: started_at,
          easing: easing, value: value.nil? ? from : value, repeat: repeat, auto_reverse: auto_reverse)
  end
end

#started_atObject (readonly)

Returns the value of attribute started_at

Returns:

  • (Object)

    the current value of started_at



45
46
47
# File 'lib/plushie/animation/tween.rb', line 45

def started_at
  @started_at
end

#toObject (readonly)

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



45
46
47
# File 'lib/plushie/animation/tween.rb', line 45

def to
  @to
end

#valueObject (readonly)

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



45
46
47
# File 'lib/plushie/animation/tween.rb', line 45

def value
  @value
end

Instance Method Details

#with(**changes) ⇒ Object Originally defined in module Model::Extensions

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.

Return a new instance with the given fields replaced. Unspecified fields carry over from the current instance.

model.with(count: model.count + 1)