Class: Plushie::Animation::Tween::State
- Inherits:
-
Data
- Object
- Data
- Plushie::Animation::Tween::State
- Includes:
- Model::Extensions
- Defined in:
- lib/plushie/animation/tween.rb
Overview
Immutable animation state.
Instance Attribute Summary collapse
-
#auto_reverse ⇒ Object
readonly
Returns the value of attribute auto_reverse.
-
#auto_reverse [Boolean] swap from/to on each cycle([Boolean]) ⇒ Object
readonly
Immutable animation state.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#easing ⇒ Object
readonly
Returns the value of attribute easing.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#repeat ⇒ Object
readonly
Returns the value of attribute repeat.
-
#repeat [Integer, :forever, nil] remaining repeat count([Integer,: forever, nil]) ⇒ Object
readonly
Immutable animation state.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(from:, to:, duration:, started_at: nil, easing: :linear, value: nil, repeat: nil, auto_reverse: false) ⇒ State
constructor
A new instance of State.
-
#with(**changes) ⇒ Object
included
from Model::Extensions
private
Return a new instance with the given fields replaced.
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_reverse ⇒ Object (readonly)
Returns the value of attribute 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 |
#duration ⇒ Object (readonly)
Returns the value of attribute duration
45 46 47 |
# File 'lib/plushie/animation/tween.rb', line 45 def duration @duration end |
#easing ⇒ Object (readonly)
Returns the value of attribute easing
45 46 47 |
# File 'lib/plushie/animation/tween.rb', line 45 def easing @easing end |
#from ⇒ Object (readonly)
Returns the value of attribute from
45 46 47 |
# File 'lib/plushie/animation/tween.rb', line 45 def from @from end |
#repeat ⇒ Object (readonly)
Returns the value of attribute 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_at ⇒ Object (readonly)
Returns the value of attribute started_at
45 46 47 |
# File 'lib/plushie/animation/tween.rb', line 45 def started_at @started_at end |
#to ⇒ Object (readonly)
Returns the value of attribute to
45 46 47 |
# File 'lib/plushie/animation/tween.rb', line 45 def to @to end |
#value ⇒ Object (readonly)
Returns the value of attribute 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)