2008-10-12 19:03:06 -07:00
|
|
|
class Sass::Script::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
|
|
|
|
|
2008-10-12 20:26:56 -07:00
|
|
|
def perform(environment)
|
2008-10-12 19:03:06 -07:00
|
|
|
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 inspect
|
|
|
|
value.inspect
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_bool
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2008-12-25 13:27:15 -08:00
|
|
|
def ==(other)
|
|
|
|
eq(other).to_bool
|
|
|
|
end
|
|
|
|
|
2008-10-12 19:03:06 -07:00
|
|
|
def to_i
|
2008-12-24 20:03:09 -08:00
|
|
|
raise Sass::SyntaxError.new("#{self.inspect} is not an integer.")
|
2008-10-12 19:03:06 -07:00
|
|
|
end
|
|
|
|
end
|