Sha256: d0f0eef05ffff917890bce00aa34d5cab3bf686127a5f4a74e043ba1e693a827

Contents?: true

Size: 700 Bytes

Versions: 17

Compression:

Stored size: 700 Bytes

Contents

module Roadie
  class StyleDeclaration
    include Comparable
    attr_reader :property, :value, :important, :specificity

    def initialize(property, value, important, specificity)
      @property = property
      @value = value
      @important = important
      @specificity = specificity
    end

    def important?
      @important
    end

    def <=>(other)
      if important == other.important
        specificity <=> other.specificity
      else
        important ? 1 : -1
      end
    end

    def to_s
      [property, value].join(':')
    end

    def inspect
      extra = [important ? '!important' : nil, specificity].compact
      "#{to_s} (#{extra.join(' , ')})"
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
roadie-2.3.4 lib/roadie/style_declaration.rb
roadie-2.3.3 lib/roadie/style_declaration.rb
roadie-2.3.2 lib/roadie/style_declaration.rb
roadie-2.3.1 lib/roadie/style_declaration.rb
roadie-2.3.0 lib/roadie/style_declaration.rb
roadie-2.3.0.pre1 lib/roadie/style_declaration.rb
roadie-2.2.0 lib/roadie/style_declaration.rb
roadie-2.1.0 lib/roadie/style_declaration.rb
roadie-2.1.0.pre2 lib/roadie/style_declaration.rb
roadie-2.1.0.pre1 lib/roadie/style_declaration.rb
roadie-2.0.0 lib/roadie/style_declaration.rb
roadie-1.1.3 lib/roadie/style_declaration.rb
roadie-1.1.1 lib/roadie/style_declaration.rb
roadie-1.1.2 lib/roadie/style_declaration.rb
roadie-1.1.0 lib/roadie/style_declaration.rb
roadie-1.0.1 lib/roadie/style_declaration.rb
roadie-1.0.0 lib/roadie/style_declaration.rb