Class: Sass::Script::Value::Bool

Inherits:
Base
  • Object
show all
Defined in:
lib/sass/script/value/bool.rb

Overview

A SassScript object representing a boolean (true or false) value.

Constant Summary collapse

TRUE =

The true value in SassScript.

This is assigned before new is overridden below so that we use the default implementation.

new(true)
FALSE =

The false value in SassScript.

This is assigned before new is overridden below so that we use the default implementation.

new(false)

Instance Attribute Summary collapse

Attributes inherited from Base

#options, #source_range

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, #_perform, #assert_int!, #bracketed, #div, #eq, #eql?, #hash, #initialize, #inspect, #minus, #neq, #null?, #plus, #separator, #single_eq, #to_a, #to_h, #to_i, #unary_div, #unary_minus, #unary_not, #unary_plus, #with_contents

Constructor Details

This class inherits a constructor from Sass::Script::Value::Base

Instance Attribute Details

#valueBoolean (readonly) Also known as: to_bool

The Ruby value of the boolean.

Returns:

  • (Boolean)


26
27
28
# File 'lib/sass/script/value/bool.rb', line 26

def value
  @value
end

Class Method Details

.new(value) ⇒ Bool

We override object creation so that users of the core API will not need to know that booleans are specific constants.

Parameters:

  • value

    A ruby value that will be tested for truthiness.

Returns:

  • (Bool)

    TRUE if value is truthy, FALSE if value is falsey



19
20
21
# File 'lib/sass/script/value/bool.rb', line 19

def self.new(value)
  value ? TRUE : FALSE
end

Instance Method Details

#to_s(opts = {}) ⇒ String Also known as: to_sass

Returns "true" or "false".

Returns:

  • (String)

    "true" or "false"



30
31
32
# File 'lib/sass/script/value/bool.rb', line 30

def to_s(opts = {})
  @value.to_s
end