Class: Inkcite::Animation::Keyframe
- Inherits:
-
Object
- Object
- Inkcite::Animation::Keyframe
- Defined in:
- lib/inkcite/animation.rb
Instance Attribute Summary collapse
-
#percent ⇒ Object
readonly
Returns the value of attribute percent.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
-
#add(key, val) ⇒ Object
For style chaining - e.g.
- #add_with_prefixes(key, val, ctx) ⇒ Object
-
#append(key, val) ⇒ Object
Appends a value to an existing key.
-
#initialize(percent, ctx, styles = {}) ⇒ Keyframe
constructor
A new instance of Keyframe.
- #to_css(prefix) ⇒ Object
Constructor Details
#initialize(percent, ctx, styles = {}) ⇒ Keyframe
Returns a new instance of Keyframe.
8 9 10 11 12 13 14 15 16 |
# File 'lib/inkcite/animation.rb', line 8 def initialize percent, ctx, styles={} # Animation percents are always rounded to the nearest whole number. @percent = percent.round(0) # Instantiate a new Style for this percentage. @style = Inkcite::Renderer::Style.new("#{@percent}%", ctx, styles) end |
Instance Attribute Details
#percent ⇒ Object (readonly)
Returns the value of attribute percent.
6 7 8 |
# File 'lib/inkcite/animation.rb', line 6 def percent @percent end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
6 7 8 |
# File 'lib/inkcite/animation.rb', line 6 def style @style end |
Instance Method Details
#[](key) ⇒ Object
18 19 20 |
# File 'lib/inkcite/animation.rb', line 18 def [] key @style[key] end |
#[]=(key, val) ⇒ Object
22 23 24 |
# File 'lib/inkcite/animation.rb', line 22 def []= key, val @style[key] = val end |
#add(key, val) ⇒ Object
For style chaining - e.g. keyframe.add(:key1, ‘val’).add(:key)
27 28 29 30 |
# File 'lib/inkcite/animation.rb', line 27 def add key, val @style[key] = val self end |
#add_with_prefixes(key, val, ctx) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/inkcite/animation.rb', line 41 def add_with_prefixes key, val, ctx ctx.prefixes.each do |prefix| _key = "#{prefix}#{key}".to_sym self[_key] = val end self end |
#append(key, val) ⇒ Object
Appends a value to an existing key
33 34 35 36 37 38 39 |
# File 'lib/inkcite/animation.rb', line 33 def append key, val @style[key] ||= '' @style[key] << ' ' unless @style[key].blank? @style[key] << val end |
#to_css(prefix) ⇒ Object
51 52 53 |
# File 'lib/inkcite/animation.rb', line 51 def to_css prefix @style.to_css(prefix) end |