Sha256: 9f48042eccb6abfd95d391a61b0c76560af1c7e4b0026441791514823ab36cff

Contents?: true

Size: 884 Bytes

Versions: 13

Compression:

Stored size: 884 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
      @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

13 entries across 13 versions & 1 rubygems

Version Path
roadie-3.3.0 lib/roadie/style_block.rb
roadie-3.2.2 lib/roadie/style_block.rb
roadie-3.2.1 lib/roadie/style_block.rb
roadie-3.2.0 lib/roadie/style_block.rb
roadie-3.1.1 lib/roadie/style_block.rb
roadie-3.1.0 lib/roadie/style_block.rb
roadie-3.1.0.rc1 lib/roadie/style_block.rb
roadie-3.0.5 lib/roadie/style_block.rb
roadie-3.0.4 lib/roadie/style_block.rb
roadie-3.0.3 lib/roadie/style_block.rb
roadie-3.0.2 lib/roadie/style_block.rb
roadie-3.0.1 lib/roadie/style_block.rb
roadie-3.0.0 lib/roadie/style_block.rb