### Home Classes Methods

### In Files

- lib/sass/script/value/base.rb

### Parent

Object

### Methods

- ::new
- #==
- #_perform
- #assert_int!
- #div
- #eq
- #eql?
- #hash
- #inspect
- #minus
- #neq
- #null?
- #options
- #plus
- #separator
- #single_eq
- #to_a
- #to_bool
- #to_h
- #to_i
- #to_s
- #to_sass
- #unary_div
- #unary_minus
- #unary_not
- #unary_plus

### Class/Module Index

Quicksearch

- Sass
- Sass::BaseEnvironment
- Sass::CSS
- Sass::CacheStores
- Sass::CacheStores::Base
- Sass::CacheStores::Chain
- Sass::CacheStores::Filesystem
- Sass::CacheStores::Memory
- Sass::CacheStores::Null
- Sass::Callbacks
- Sass::Callbacks::InstanceMethods
- Sass::Engine
- Sass::Engine::Line
- Sass::Environment
- Sass::Exec
- Sass::Exec::Base
- Sass::Exec::SassConvert
- Sass::Exec::SassScss
- Sass::Exec::SassScss::Sass::Plugin.compiler
- Sass::Features
- Sass::Importers
- Sass::Importers::Base
- Sass::Importers::Filesystem
- Sass::Logger
- Sass::Logger::Base
- Sass::Logger::LogLevel
- Sass::Logger::LogLevel::ClassMethods
- Sass::Media
- Sass::Media::Query
- Sass::Media::QueryList
- Sass::Plugin
- Sass::Plugin::Compiler
- Sass::Plugin::Configuration
- Sass::Plugin::MerbBootLoader
- Sass::Plugin::Rack
- Sass::Plugin::StalenessChecker
- Sass::ReadOnlyEnvironment
- Sass::Repl
- Sass::SCSS
- Sass::SCSS::CssParser
- Sass::SCSS::Parser
- Sass::SCSS::RX
- Sass::SCSS::ScriptLexer
- Sass::SCSS::ScriptParser
- Sass::SCSS::StaticParser
- Sass::Script
- Sass::Script::CssLexer
- Sass::Script::CssParser
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::Lexer
- Sass::Script::Parser
- Sass::Script::Tree
- Sass::Script::Tree::Funcall
- Sass::Script::Tree::Interpolation
- Sass::Script::Tree::ListLiteral
- Sass::Script::Tree::Literal
- Sass::Script::Tree::MapLiteral
- Sass::Script::Tree::Node
- Sass::Script::Tree::Operation
- Sass::Script::Tree::Selector
- Sass::Script::Tree::StringInterpolation
- Sass::Script::Tree::UnaryOperation
- Sass::Script::Tree::Variable
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::Bool
- Sass::Script::Value::Color
- Sass::Script::Value::Helpers
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Script::Value::Null
- Sass::Script::Value::Number
- Sass::Script::Value::String
- Sass::Selector
- Sass::Selector::AbstractSequence
- Sass::Selector::Attribute
- Sass::Selector::Class
- Sass::Selector::CommaSequence
- Sass::Selector::Element
- Sass::Selector::Id
- Sass::Selector::Parent
- Sass::Selector::Placeholder
- Sass::Selector::Pseudo
- Sass::Selector::Sequence
- Sass::Selector::Simple
- Sass::Selector::SimpleSequence
- Sass::Selector::Universal
- Sass::SemiGlobalEnvironment
- Sass::Shared
- Sass::Source
- Sass::Source::Map
- Sass::Source::Map::Mapping
- Sass::Source::Position
- Sass::Source::Range
- Sass::Stack
- Sass::Stack::Frame
- Sass::Supports
- Sass::Supports::Condition
- Sass::Supports::Declaration
- Sass::Supports::Interpolation
- Sass::Supports::Negation
- Sass::Supports::Operator
- Sass::SyntaxError
- Sass::Tree
- Sass::Tree::AtRootNode
- Sass::Tree::CharsetNode
- Sass::Tree::CommentNode
- Sass::Tree::ContentNode
- Sass::Tree::CssImportNode
- Sass::Tree::DebugNode
- Sass::Tree::DirectiveNode
- Sass::Tree::EachNode
- Sass::Tree::ErrorNode
- Sass::Tree::ExtendNode
- Sass::Tree::ForNode
- Sass::Tree::FunctionNode
- Sass::Tree::IfNode
- Sass::Tree::ImportNode
- Sass::Tree::KeyframeRuleNode
- Sass::Tree::MediaNode
- Sass::Tree::MixinDefNode
- Sass::Tree::MixinNode
- Sass::Tree::Node
- Sass::Tree::PropNode
- Sass::Tree::ReturnNode
- Sass::Tree::RootNode
- Sass::Tree::RuleNode
- Sass::Tree::SupportsNode
- Sass::Tree::TraceNode
- Sass::Tree::VariableNode
- Sass::Tree::Visitors
- Sass::Tree::Visitors::Base
- Sass::Tree::Visitors::CheckNesting
- Sass::Tree::Visitors::Convert
- Sass::Tree::Visitors::Cssize
- Sass::Tree::Visitors::Cssize::Bubble
- Sass::Tree::Visitors::DeepCopy
- Sass::Tree::Visitors::Extend
- Sass::Tree::Visitors::Perform
- Sass::Tree::Visitors::SetOptions
- Sass::Tree::Visitors::ToCss
- Sass::Tree::WarnNode
- Sass::Tree::WhileNode
- Sass::UnitConversionError
- Sass::Util
- Sass::Util::CrossPlatformRandom
- Sass::Util::MultibyteStringScanner
- Sass::Util::NormalizedMap
- Sass::Util::StaticConditionalContext
- Sass::Util::SubsetMap
- Sass::Util::Test
- Sass::Version
- ActionController
- ActionController::Base
- Object
- OrderedHash

No matching classes.

# Sass::Script::Value::Base

The abstract superclass for SassScript objects.

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

### Attributes

options[W]

Sets the options hash for this node, as well as for all child nodes. See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.

@param options [{Symbol => Object}] The options

source_range[RW]

The source range in the document on which this node appeared.

@return [Sass::Source::Range]

value[R]

Returns the Ruby value of the value. The type of this value varies based on the subclass.

@return [Object]

### Public Class Methods

new(value = nil) click to toggle source

Creates a new value.

@param value [Object] The object for {#value}

    # File lib/sass/script/value/base.rb, line 22
    def initialize(value = nil)
      value.freeze unless value.nil? || value == true || value == false
      @value = value
    end

### Public Instance Methods

==(other) click to toggle source

Compares this object with another.

@param other [Object] The object to compare with @return [Boolean] Whether or not this value is equivalent to `other`

    # File lib/sass/script/value/base.rb, line 174
    def ==(other)
      eq(other).to_bool
    end

assert_int!() click to toggle source

@raise [Sass::SyntaxError] if this value isn’t an integer

    # File lib/sass/script/value/base.rb, line 185
    def assert_int!; to_i; end

div(other) click to toggle source

The SassScript `/` operation.

@param other [Value] The right-hand side of the operator @return [Script::Value::String] A string containing both values

    separated by `"/"`

    # File lib/sass/script/value/base.rb, line 117
    def div(other)
      Sass::Script::Value::String.new("#{to_s}/#{other.to_s}")
    end

eq(other) click to toggle source

The SassScript `==` operation. **Note that this returns a {Sass::Script::Value::Bool} object, not a Ruby boolean**.

@param other [Value] The right-hand side of the operator @return [Sass::Script::Value::Bool] True if this value is the same as the other,

    false otherwise

    # File lib/sass/script/value/base.rb, line 57
    def eq(other)
      Sass::Script::Value::Bool.new(self.class == other.class && value == other.value)
    end

eql?(other) click to toggle source

    # File lib/sass/script/value/base.rb, line 156
    def eql?(other)
      self == other
    end

hash() click to toggle source

Returns the hash code of this value. Two objects’ hash codes should be equal if the objects are equal.

@return [Fixnum] The hash code.

    # File lib/sass/script/value/base.rb, line 152
    def hash
      value.hash
    end

inspect() click to toggle source

@return [String] A readable representation of the value

    # File lib/sass/script/value/base.rb, line 161
    def inspect
      value.inspect
    end

minus(other) click to toggle source

The SassScript `-` operation.

@param other [Value] The right-hand side of the operator @return [Script::Value::String] A string containing both values

    separated by `"-"`

    # File lib/sass/script/value/base.rb, line 108
    def minus(other)
      Sass::Script::Value::String.new("#{to_s}-#{other.to_s}")
    end

neq(other) click to toggle source

The SassScript `!=` operation. **Note that this returns a {Sass::Script::Value::Bool} object, not a Ruby boolean**.

@param other [Value] The right-hand side of the operator @return [Sass::Script::Value::Bool] False if this value is the same as the other,

    true otherwise

    # File lib/sass/script/value/base.rb, line 68
    def neq(other)
      Sass::Script::Value::Bool.new(!eq(other).to_bool)
    end

null?() click to toggle source

Returns whether or not this object is null.

@return [Boolean] `false`

    # File lib/sass/script/value/base.rb, line 226
    def null?
      false
    end

options() click to toggle source

Returns the options hash for this node.

@return [{Symbol => Object}] @raise [Sass::SyntaxError] if the options hash hasn’t been set.

    This should only happen when the value was created
    outside of the parser and \{#to\_s} was called on it

    # File lib/sass/script/value/base.rb, line 40
    def options
      return @options if @options
      raise Sass::SyntaxError.new(The #options attribute is not set on this #{self.class}.  This error is probably occurring because #to_s was called  on this value within a custom Sass function without first  setting the #options attribute.)
    end

plus(other) click to toggle source

The SassScript `+` operation.

@param other [Value] The right-hand side of the operator @return [Script::Value::String] A string containing both values

    without any separation

    # File lib/sass/script/value/base.rb, line 98
    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

separator() click to toggle source

Returns the separator for this value. For non-list-like values or the empty list, this will be `nil`. For lists or maps, it will be `:space` or `:comma`.

@return [Symbol]

    # File lib/sass/script/value/base.rb, line 192
    def separator; nil; end

single_eq(other) click to toggle source

The SassScript `=` operation (used for proprietary MS syntax like `alpha(opacity=20)`).

@param other [Value] The right-hand side of the operator @return [Script::Value::String] A string containing both values

    separated by `"="`

    # File lib/sass/script/value/base.rb, line 89
    def single_eq(other)
      Sass::Script::Value::String.new("#{to_s}=#{other.to_s}")
    end

to_a() click to toggle source

Returns the value of this value as a list. Single values are considered the same as single-element lists.

@return [Array<Value>] This value as a list

    # File lib/sass/script/value/base.rb, line 198
    def to_a
      [self]
    end

to_bool() click to toggle source

@return [Boolean] `true` (the Ruby boolean value)

    # File lib/sass/script/value/base.rb, line 166
    def to_bool
      true
    end

to_h() click to toggle source

Returns the value of this value as a hash. Most values don’t have hash representations, but [Map]s and empty [List]s do.

@return [Hash<Value, Value>] This value as a hash @raise [Sass::SyntaxError] if this value doesn’t have a hash representation

    # File lib/sass/script/value/base.rb, line 207
    def to_h
      raise Sass::SyntaxError.new("#{inspect} is not a map.")
    end

to_i() click to toggle source

@return [Fixnum] The integer value of this value @raise [Sass::SyntaxError] if this value isn’t an integer

    # File lib/sass/script/value/base.rb, line 180
    def to_i
      raise Sass::SyntaxError.new("#{inspect} is not an integer.")
    end

to_s(opts = {}) click to toggle source

Returns the string representation of this value as it would be output to the CSS document.

@options opts :quote [String]

    The preferred quote style for quoted strings. If `:none`, strings are
    always emitted unquoted.

@return [String]

    # File lib/sass/script/value/base.rb, line 218
    def to_s(opts = {})
      Sass::Util.abstract(self)
    end

Also aliased as: to_sass
to_sass(opts = {}) click to toggle source
Alias for: to_s
unary_div() click to toggle source

The SassScript unary `/` operation (e.g. `/$a`).

@param other [Value] The right-hand side of the operator @return [Script::Value::String] A string containing the value

    preceded by `"/"`

    # File lib/sass/script/value/base.rb, line 144
    def unary_div
      Sass::Script::Value::String.new("/#{to_s}")
    end

unary_minus() click to toggle source

The SassScript unary `-` operation (e.g. `-$a`).

@param other [Value] The right-hand side of the operator @return [Script::Value::String] A string containing the value

    preceded by `"-"`

    # File lib/sass/script/value/base.rb, line 135
    def unary_minus
      Sass::Script::Value::String.new("-#{to_s}")
    end

unary_not() click to toggle source

The SassScript `==` operation. **Note that this returns a {Sass::Script::Value::Bool} object, not a Ruby boolean**.

@param other [Value] The right-hand side of the operator @return [Sass::Script::Value::Bool] True if this value is the same as the other,

    false otherwise

    # File lib/sass/script/value/base.rb, line 79
    def unary_not
      Sass::Script::Value::Bool.new(!to_bool)
    end

unary_plus() click to toggle source

The SassScript unary `+` operation (e.g. `+$a`).

@param other [Value] The right-hand side of the operator @return [Script::Value::String] A string containing the value

    preceded by `"+"`

    # File lib/sass/script/value/base.rb, line 126
    def unary_plus
      Sass::Script::Value::String.new("+#{to_s}")
    end

### Protected Instance Methods

_perform(environment) click to toggle source

Evaluates the value.

@param environment [Sass::Environment] The environment in which to evaluate the SassScript @return [Value] This value

    # File lib/sass/script/value/base.rb, line 236
    def _perform(environment)
      self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.