Sha256: 9d121eed8841ffb8bcb9283e6b5d24866067715ccce5bac2e7a3d17429b2840f

Contents?: true

Size: 1.48 KB

Versions: 23

Compression:

Stored size: 1.48 KB

Contents

module Sass::Script
  class Literal # :nodoc:
    require 'sass/script/string'
    require 'sass/script/number'
    require 'sass/script/color'
    require 'sass/script/bool'

    attr_reader :value

    def initialize(value = nil)
      @value = value
    end

    def perform(environment)
      self
    end

    def and(other)
      to_bool ? other : self
    end

    def or(other)
      to_bool ? self : other
    end

    def eq(other)
      Sass::Script::Bool.new(self.class == other.class && self.value == other.value)
    end

    def neq(other)
      Sass::Script::Bool.new(!eq(other).to_bool)
    end

    def unary_not
      Sass::Script::Bool.new(!to_bool)
    end

    def concat(other)
      Sass::Script::String.new("#{self.to_s} #{other.to_s}")
    end

    def comma(other)
      Sass::Script::String.new("#{self.to_s}, #{other.to_s}")
    end

    def plus(other)
      Sass::Script::String.new(self.to_s + other.to_s)
    end

    def minus(other)
      Sass::Script::String.new("#{self.to_s}-#{other.to_s}")
    end

    def div(other)
      Sass::Script::String.new("#{self.to_s}/#{other.to_s}")
    end

    def unary_minus
      Sass::Script::String.new("-#{self.to_s}")
    end

    def unary_div
      Sass::Script::String.new("/#{self.to_s}")
    end

    def inspect
      value.inspect
    end

    def to_bool
      true
    end

    def ==(other)
      eq(other).to_bool
    end

    def to_i
      raise Sass::SyntaxError.new("#{self.inspect} is not an integer.")
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
gohanlonllc-haml-2.1.0.20080513000000 lib/sass/script/literal.rb
gohanlonllc-haml-2.1.0 lib/sass/script/literal.rb
haml-edge-2.1.10 lib/sass/script/literal.rb
haml-edge-2.1.11 lib/sass/script/literal.rb
haml-edge-2.1.12 lib/sass/script/literal.rb
haml-edge-2.1.1 lib/sass/script/literal.rb
haml-edge-2.1.2 lib/sass/script/literal.rb
haml-edge-2.1.14 lib/sass/script/literal.rb
haml-edge-2.1.15 lib/sass/script/literal.rb
haml-edge-2.1.16 lib/sass/script/literal.rb
haml-edge-2.1.17 lib/sass/script/literal.rb
haml-edge-2.1.18 lib/sass/script/literal.rb
haml-edge-2.1.19 lib/sass/script/literal.rb
haml-edge-2.1.20 lib/sass/script/literal.rb
haml-edge-2.1.21 lib/sass/script/literal.rb
haml-edge-2.1.3 lib/sass/script/literal.rb
haml-edge-2.1.4 lib/sass/script/literal.rb
haml-edge-2.1.5 lib/sass/script/literal.rb
haml-edge-2.1.13 lib/sass/script/literal.rb
haml-edge-2.1.7 lib/sass/script/literal.rb