class Sass::Script::Literal

The operations listed here are just the defaults.
are designed to be overridden by subclasses which may change the semantics somewhat.
Many of these methods, especially the ones that correspond to SassScript operations,
The abstract superclass for SassScript objects.

def ==(other)

Returns:
  • (Boolean) - Whether or not this literal is equivalent to `other`

Parameters:
  • other (Object) -- The object to compare with
def ==(other)
  eq(other).to_bool
end

def and(other)

Returns:
  • (Literal) - The result of a logical and:

Parameters:
  • other (Literal) -- The right-hand side of the operator
def and(other)
  to_bool ? other : self
end

def assert_int!; to_i; end

Raises:
  • (Sass::SyntaxError) - if this literal isn't an integer
def assert_int!; to_i; end

def comma(other)

Returns:
  • (Script::String) - A string containing both literals

Parameters:
  • other (Literal) -- The right-hand side of the operator
def comma(other)
  Sass::Script::String.new("#{self.to_s}, #{other.to_s}")
end

def concat(other)

Returns:
  • (Script::String) - A string containing both literals

Parameters:
  • other (Literal) -- The right-hand side of the operator
def concat(other)
  Sass::Script::String.new("#{self.to_s} #{other.to_s}")
end

def div(other)

Returns:
  • (Script::String) - A string containing both literals

Parameters:
  • other (Literal) -- The right-hand side of the operator
def div(other)
  Sass::Script::String.new("#{self.to_s}/#{other.to_s}")
end

def eq(other)

Returns:
  • (Bool) - True if this literal is the same as the other,

Parameters:
  • other (Literal) -- The right-hand side of the operator
def eq(other)
  Sass::Script::Bool.new(self.class == other.class && self.value == other.value)
end

def initialize(value = nil)

Parameters:
  • value (Object) -- The object for \{#value}
def initialize(value = nil)
  @value = value
end

def inspect

Returns:
  • (String) - A readable representation of the literal
def inspect
  value.inspect
end

def minus(other)

Returns:
  • (Script::String) - A string containing both literals

Parameters:
  • other (Literal) -- The right-hand side of the operator
def minus(other)
  Sass::Script::String.new("#{self.to_s}-#{other.to_s}")
end

def neq(other)

Returns:
  • (Bool) - False if this literal is the same as the other,

Parameters:
  • other (Literal) -- The right-hand side of the operator
def neq(other)
  Sass::Script::Bool.new(!eq(other).to_bool)
end

def or(other)

Returns:
  • (Literal) - The result of the logical or:

Parameters:
  • other (Literal) -- The right-hand side of the operator
def or(other)
  to_bool ? self : other
end

def perform(environment)

Returns:
  • (Literal) - This literal

Parameters:
  • environment (Sass::Environment) -- The environment in which to evaluate the SassScript
def perform(environment)
  self
end

def plus(other)

Returns:
  • (Script::String) - A string containing both literals

Parameters:
  • other (Literal) -- The right-hand side of the operator
def plus(other)
  Sass::Script::String.new(self.to_s + other.to_s)
end

def to_bool

Returns:
  • (Boolean) - `true` (the Ruby boolean value)
def to_bool
  true
end

def to_i

Raises:
  • (Sass::SyntaxError) - if this literal isn't an integer

Returns:
  • (Fixnum) - The integer value of this literal
def to_i
  raise Sass::SyntaxError.new("#{self.inspect} is not an integer.")
end

def unary_div

Returns:
  • (Script::String) - A string containing the literal

Parameters:
  • other (Literal) -- The right-hand side of the operator
def unary_div
  Sass::Script::String.new("/#{self.to_s}")
end

def unary_minus

Returns:
  • (Script::String) - A string containing the literal

Parameters:
  • other (Literal) -- The right-hand side of the operator
def unary_minus
  Sass::Script::String.new("-#{self.to_s}")
end

def unary_not

Returns:
  • (Bool) - True if this literal is the same as the other,

Parameters:
  • other (Literal) -- The right-hand side of the operator
def unary_not
  Sass::Script::Bool.new(!to_bool)
end