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

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

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.

Parameters:

  • from: (Numeric)
  • to: (Numeric)
  • duration: (Integer)
  • started_at: (Integer, nil) (defaults to: nil)
  • easing: (Symbol, ^(Float) -> Float) (defaults to: :linear)
  • value: (Numeric, nil) (defaults to: nil)
  • repeat: (Integer, Symbol, nil) (defaults to: nil)
  • auto_reverse: (Boolean) (defaults to: false)


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

#withState

Parameters:

  • changes (Object)

Returns:



17
# File 'sig/plushie/animation.rbs', line 17

def with: (**untyped changes) -> State