Class Sass::Script::Literal
In: lib/sass/script/literal.rb
Parent: Node

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.

Methods

==   _perform   and   assert_int!   children   comma   concat   div   eq   inspect   minus   neq   new   options   or   plus   single_eq   to_bool   to_i   to_s   to_sass   unary_div   unary_minus   unary_not   unary_plus  

Attributes

value  [R]  Returns the Ruby value of the literal. The type of this value varies based on the subclass.

@return [Object]

Public Class methods

Creates a new literal.

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

Public Instance methods

Compares this object with another.

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

The SassScript `and` operation.

@param other [Literal] The right-hand side of the operator @return [Literal] The result of a logical and:

  `other` if this literal isn't a false {Bool},
  and this literal otherwise

@raise [Sass::SyntaxError] if this literal isn‘t an integer

Returns an empty array.

@return [Array<Node>] empty @see Node#children

The SassScript `,` operation (e.g. `$a, $b`, `"foo", "bar"`).

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

  separated by `", "`

The SassScript default operation (e.g. `$a $b`, `"foo" "bar"`).

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

  separated by a space

The SassScript `/` operation.

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

  separated by `"/"`

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

@param other [Literal] The right-hand side of the operator @return [Bool] True if this literal is the same as the other,

  false otherwise

@return [String] A readable representation of the literal

The SassScript `-` operation.

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

  separated by `"-"`

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

@param other [Literal] The right-hand side of the operator @return [Bool] False if this literal is the same as the other,

  true otherwise

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 literal was created
  outside of the parser and \{#to\_s} was called on it

The SassScript `or` operation.

@param other [Literal] The right-hand side of the operator @return [Literal] The result of the logical or:

  this literal if it isn't a false {Bool},
  and `other` otherwise

The SassScript `+` operation.

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

  without any separation

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

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

  separated by `"="`

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

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

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

@return [String]

to_sass(opts = {})

Alias for to_s

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

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

  preceded by `"/"`

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

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

  preceded by `"-"`

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

@param other [Literal] The right-hand side of the operator @return [Bool] True if this literal is the same as the other,

  false otherwise

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

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

  preceded by `"+"`

Protected Instance methods

Evaluates the literal.

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

[Validate]