class StyleInliner::DeclarationBlock

Public Class Methods

new(rule_sets) click to toggle source

@param rule_sets [Array<StyleInliner::RuleSet>]

# File lib/style_inliner/declaration_block.rb, line 4
def initialize(rule_sets)
  @rule_sets = rule_sets
end

Public Instance Methods

delete_property(property_name) click to toggle source
# File lib/style_inliner/declaration_block.rb, line 8
def delete_property(property_name)
  merged_rule_set.instance_variable_get(:@declarations).delete(property_name)
end
get_property(property_name) click to toggle source

@return [String]

# File lib/style_inliner/declaration_block.rb, line 13
def get_property(property_name)
  merged_rule_set[property_name]
end
to_s() click to toggle source

@return [String]

# File lib/style_inliner/declaration_block.rb, line 18
def to_s
  merged_rule_set.declarations_to_s.gsub('"', "'").split(/;(?![^(]*\))/).map(&:strip).sort.join("; ")
end

Private Instance Methods

merged_rule_set() click to toggle source

@return [CssParser::RuleSet]

# File lib/style_inliner/declaration_block.rb, line 25
def merged_rule_set
  @merged_rule_set ||= ::CssParser.merge(
    @rule_sets.map do |rule_set|
      ::CssParser::RuleSet.new(
        nil,
        rule_set.declarations,
        rule_set.specificity,
      )
    end
  ).tap(&:expand_shorthand!)
end