Sha256: 8ca8e67c70f514451e36571e8192b45ea5c91b476e25fa8a1d368f0e93e4b87f

Contents?: true

Size: 953 Bytes

Versions: 1

Compression:

Stored size: 953 Bytes

Contents

require 'forwardable'

module Roadie
  # @api private
  # A style block is the combination of a {Selector} and a list of {StyleProperty}.
  class StyleBlock
    extend Forwardable
    attr_reader :selector, :properties

    # @param [Selector] selector
    # @param [Array<StyleProperty>] properties
    def initialize(selector, properties)
      @selector = selector
      # TODO: Should we use {StyleProperties} instead? Why? Why not?
      @properties = properties
    end

    # @!method specificity
    #   @see Selector#specificity
    # @!method inlinable?
    #   @see Selector#inlinable?
    def_delegators :selector, :specificity, :inlinable?
    # @!method selector_string
    #   @see Selector#to_s
    def_delegator :selector, :to_s, :selector_string

    # String representation of the style block. This is valid CSS and can be
    # used in the DOM.
    def to_s
      "#{selector}{#{properties.map(&:to_s).join(';')}}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roadie-3.0.0.pre1 lib/roadie/style_block.rb