Sha256: c5a892a646087a4c6170982c8f7f7345c578718671951ceb9e28b221ceb5a1fe

Contents?: true

Size: 775 Bytes

Versions: 5

Compression:

Stored size: 775 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_with_important].join(':')
    end

    def inspect
      "#{to_s} (#{specificity})"
    end

    private
    def value_with_important
      if important
        "#{value} !important"
      else
        value
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
roadie-2.4.3 lib/roadie/style_declaration.rb
md-roadie-2.4.2.md.1 lib/roadie/style_declaration.rb
roadie-2.4.2 lib/roadie/style_declaration.rb
roadie-2.4.1 lib/roadie/style_declaration.rb
roadie-2.4.0 lib/roadie/style_declaration.rb