class Sass::Script::Value::Base
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 value is equivalent to `other`
Parameters:
-
other
(Object
) -- The object to compare with
def ==(other) eq(other).to_bool end
def _perform(environment)
-
(Value)
- This value
Parameters:
-
environment
(Sass::Environment
) -- The environment in which to evaluate the SassScript
def _perform(environment) self end
def assert_int!; to_i; end
-
(Sass::SyntaxError)
- if this value isn't an integer
def assert_int!; to_i; end
def bracketed; false; end
-
(Boolean)
-
def bracketed; false; end
def div(other)
-
(Script::Value::String)
- A string containing both values
Parameters:
-
other
(Value
) -- The right-hand side of the operator
def div(other) Sass::Script::Value::String.new("#{self}/#{other}") end
def eq(other)
-
(Sass::Script::Value::Bool)
- True if this value is the same as the other,
Parameters:
-
other
(Value
) -- The right-hand side of the operator
def eq(other) Sass::Script::Value::Bool.new(self.class == other.class && value == other.value) end
def eql?(other)
def eql?(other) self == other end
def hash
-
(Integer for Ruby 2.4.0+, Fixnum for earlier Ruby versions)
- The hash code.
def hash value.hash end
def initialize(value = nil)
-
value
(Object
) -- The object for \{#value}
def initialize(value = nil) value.freeze unless value.nil? || value == true || value == false @value = value @options = nil end
def inspect
-
(String)
- A readable representation of the value
def inspect value.inspect end
def minus(other)
-
(Script::Value::String)
- A string containing both values
Parameters:
-
other
(Value
) -- The right-hand side of the operator
def minus(other) Sass::Script::Value::String.new("#{self}-#{other}") end
def neq(other)
-
(Sass::Script::Value::Bool)
- False if this value is the same as the other,
Parameters:
-
other
(Value
) -- The right-hand side of the operator
def neq(other) Sass::Script::Value::Bool.new(!eq(other).to_bool) end
def null?
-
(Boolean)
- `false`
def null? false end
def options
-
(Sass::SyntaxError)
- if the options hash hasn't been set.
Returns:
-
({Symbol => Object})
-
def options return @options if @options 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 value within a custom Sass function without first tting the #options attribute. end
def plus(other)
-
(Script::Value::String)
- A string containing both values
Parameters:
-
other
(Value
) -- The right-hand side of the operator
def plus(other) type = other.is_a?(Sass::Script::Value::String) ? other.type : :identifier Sass::Script::Value::String.new(to_s(:quote => :none) + other.to_s(:quote => :none), type) end
def separator; nil; end
-
(Symbol)
-
def separator; nil; end
def single_eq(other)
-
(Script::Value::String)
- A string containing both values
Parameters:
-
other
(Value
) -- The right-hand side of the operator
def single_eq(other) Sass::Script::Value::String.new("#{self}=#{other}") end
def to_a
-
(Array
- This value as a list)
def to_a [self] end
def to_bool
-
(Boolean)
- `true` (the Ruby boolean value)
def to_bool true end
def to_h
-
(Sass::SyntaxError)
- if this value doesn't have a hash representation
Returns:
-
(Hash
- This value as a hash)
def to_h raise Sass::SyntaxError.new("#{inspect} is not a map.") end
def to_i
-
(Sass::SyntaxError)
- if this value isn't an integer
Returns:
-
(Integer)
- The integer value of this value
def to_i raise Sass::SyntaxError.new("#{inspect} is not an integer.") end
def to_s(opts = {})
-
(String)
-
def to_s(opts = {}) Sass::Util.abstract(self) end
def unary_div
-
(Script::Value::String)
- A string containing the value
Parameters:
-
other
(Value
) -- The right-hand side of the operator
def unary_div Sass::Script::Value::String.new("/#{self}") end
def unary_minus
-
(Script::Value::String)
- A string containing the value
Parameters:
-
other
(Value
) -- The right-hand side of the operator
def unary_minus Sass::Script::Value::String.new("-#{self}") end
def unary_not
-
(Sass::Script::Value::Bool)
- True if this value is the same as the other,
Parameters:
-
other
(Value
) -- The right-hand side of the operator
def unary_not Sass::Script::Value::Bool.new(!to_bool) end
def unary_plus
-
(Script::Value::String)
- A string containing the value
Parameters:
-
other
(Value
) -- The right-hand side of the operator
def unary_plus Sass::Script::Value::String.new("+#{self}") end
def with_contents(contents, separator: self.separator, bracketed: self.bracketed)
-
(Sass::Script::Value::List)
-
Parameters:
-
bracketed
(Boolean
) -- Whether the new list is bracketed. Defaults to \{#bracketed}. -
separator
(Symbol
) -- The separator of the new list. Defaults to \{#separator}. -
contents
(Array
) -- The contents of the new list.
def with_contents(contents, separator: self.separator, bracketed: self.bracketed) Sass::Script::Value::List.new(contents, separator: separator, bracketed: bracketed) end