class CssCompare::CSS::Component::KeyframesSelector
Represents a rule of the @keyframe directive.
Examples:
- from { top: 0; } // also meaning the same as 0% - 50% { top: 50; } - to { top: 100; } // also meaning the same as 100%
Attributes
properties[R]
The properties specified at this rule.
@return [Hash{String => Property}]
value[R]
The value of the rule. Possible values: <‘0%’;‘100%’>.
@return [String]
Public Class Methods
new(node)
click to toggle source
@param [Sass::Tree::KeyframeRuleNode] node a rule node
of the @keyframe directive.
# File lib/css_compare/css/component/keyframes_selector.rb, line 23 def initialize(node) @value = value(node.resolved_value) @properties = {} process_properties(node.children) end
Public Instance Methods
==(other)
click to toggle source
Checks, whether two keyframes selectors are equal.
They are equal only if they have declared the same properties and they are also equal.
@param [KeyframesSelector] other the keyframes selector
to compare this with.
@return [Boolean]
Calls superclass method
CssCompare::CSS::Component::Base#==
# File lib/css_compare/css/component/keyframes_selector.rb, line 37 def ==(other) super(@properties, other.properties) end
add_property(property)
click to toggle source
Adds a new or rewrites an already existing property of this rule’s set of properties.
@return [Void]
# File lib/css_compare/css/component/keyframes_selector.rb, line 55 def add_property(property) name = property.name if @properties[name] @properties[name].merge(property) else @properties[name] = property end end
deep_copy(value = @value)
click to toggle source
# File lib/css_compare/css/component/keyframes_selector.rb, line 64 def deep_copy(value = @value) copy = dup copy.value = value copy.properties = @properties.inject({}) do |result, (k, v)| result.update(k => v.deep_copy) end end
process_properties(properties)
click to toggle source
Creates and puts te properties into the set of properties of this rule.
@return [Void]
# File lib/css_compare/css/component/keyframes_selector.rb, line 86 def process_properties(properties) properties.each do |prop| add_property(Property.new(prop, ['no condition'])) if prop.is_a?(Sass::Tree::PropNode) end end
to_json()
click to toggle source
Creates the JSON representation of this keyframes selector.
@return [Hash]
# File lib/css_compare/css/component/keyframes_selector.rb, line 76 def to_json @properties.inject({}) do |result, (name, prop)| result.update(name.to_sym => prop.to_json) end end