Class: SassC::Script::Value::Bool

Inherits:
SassC::Script::Value show all
Defined in:
lib/sassc/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 SassC::Script::Value

#options, #source_range

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SassC::Script::Value

#==, #assert_int!, #bracketed, #eql?, #hash, #initialize, #inspect, #null?, #separator, #to_a, #to_h, #to_i, #with_contents

Constructor Details

This class inherits a constructor from SassC::Script::Value

Instance Attribute Details

#valueObject (readonly) Also known as: to_bool

The pure Ruby value of this Boolean



23
24
25
# File 'lib/sassc/script/value/bool.rb', line 23

def value
  @value
end

Class Method Details

.new(value) ⇒ Object

We override object creation so that users of the core API will not need to know that booleans are specific constants. Tests value for truthiness and returns the TRUE or FALSE constant.



18
19
20
# File 'lib/sassc/script/value/bool.rb', line 18

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

Instance Method Details

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

Returns the string “true” or “false” for this value



27
28
29
# File 'lib/sassc/script/value/bool.rb', line 27

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