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)
-
(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)
-
(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
-
(Sass::SyntaxError)
- if this literal isn't an integer
def assert_int!; to_i; end
def comma(other)
-
(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)
-
(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)
-
(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)
-
(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)
-
value
(Object
) -- The object for \{#value}
def initialize(value = nil) @value = value end
def inspect
-
(String)
- A readable representation of the literal
def inspect value.inspect end
def minus(other)
-
(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)
-
(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)
-
(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)
-
(Literal)
- This literal
Parameters:
-
environment
(Sass::Environment
) -- The environment in which to evaluate the SassScript
def perform(environment) self end
def plus(other)
-
(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
-
(Boolean)
- `true` (the Ruby boolean value)
def to_bool true end
def to_i
-
(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
-
(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
-
(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
-
(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