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 _perform(environment)
-
(Literal)
- This literal
Parameters:
-
environment
(Sass::Environment
) -- The environment in which to evaluate the SassScript
def _perform(environment) self 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 children
- See: Node#children -
Returns:
-
(Array
- empty)
def children [] 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 super() 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 options
-
(Sass::SyntaxError)
- if the options hash hasn't been set.
Returns:
-
({Symbol => Object})
-
def options opts = super return opts if opts raise Sass::SyntaxError.new(<<MSG) #options attribute is not set on this #{self.class}. is error is probably occurring because #to_s was called this literal within a custom Sass function without first tting the #option attribute. 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 plus(other)
-
(Script::String)
- A string containing both literals
Parameters:
-
other
(Literal
) -- The right-hand side of the operator
def plus(other) if other.is_a?(Sass::Script::String) return Sass::Script::String.new(self.to_s + other.value, other.type) end Sass::Script::String.new(self.to_s + other.to_s) end
def single_eq(other)
-
(Script::String)
- A string containing both literals
Parameters:
-
other
(Literal
) -- The right-hand side of the operator
def single_eq(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 to_s(opts = {})
-
(String)
-
def to_s(opts = {}) raise Sass::SyntaxError.new("[BUG] All subclasses of Sass::Literal must implement #to_s.") 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
def unary_plus
-
(Script::String)
- A string containing the literal
Parameters:
-
other
(Literal
) -- The right-hand side of the operator
def unary_plus Sass::Script::String.new("+#{self.to_s}") end