Module: Sass::Value

Included in:
Boolean, Color, Function, List, Map, Null, Number, String
Defined in:
lib/sass/value.rb,
lib/sass/value/map.rb,
lib/sass/value/list.rb,
lib/sass/value/null.rb,
lib/sass/value/color.rb,
lib/sass/value/number.rb,
lib/sass/value/string.rb,
lib/sass/value/boolean.rb,
lib/sass/value/function.rb,
lib/sass/value/fuzzy_math.rb,
lib/sass/value/number/unit.rb,
lib/sass/value/argument_list.rb

Overview

The abstract base class of Sass’s value types.

Defined Under Namespace

Classes: ArgumentList, Boolean, Color, Function, List, Map, Null, Number, String

Instance Method Summary collapse

Instance Method Details

#[](index) ⇒ Value

Parameters:

  • index (Numeric)

Returns:



27
28
29
# File 'lib/sass/value.rb', line 27

def [](index)
  at(index)
end

#assert_boolean(name = nil) ⇒ Boolean

Returns:

Raises:



59
60
61
# File 'lib/sass/value.rb', line 59

def assert_boolean(name = nil)
  raise Sass::ScriptError.new("#{self} is not a boolean", name)
end

#assert_calculation(name = nil) ⇒ Object

Raises:



64
65
66
# File 'lib/sass/value.rb', line 64

def assert_calculation(name = nil)
  raise Sass::ScriptError.new("#{self} is not a calculation", name)
end

#assert_color(name = nil) ⇒ Color

Returns:

Raises:



70
71
72
# File 'lib/sass/value.rb', line 70

def assert_color(name = nil)
  raise Sass::ScriptError.new("#{self} is not a color", name)
end

#assert_function(name = nil) ⇒ Function

Returns:

Raises:



76
77
78
# File 'lib/sass/value.rb', line 76

def assert_function(name = nil)
  raise Sass::ScriptError.new("#{self} is not a function", name)
end

#assert_map(name = nil) ⇒ Map

Returns:

Raises:



82
83
84
# File 'lib/sass/value.rb', line 82

def assert_map(name = nil)
  raise Sass::ScriptError.new("#{self} is not a map", name)
end

#assert_number(name = nil) ⇒ Number

Returns:

Raises:



88
89
90
# File 'lib/sass/value.rb', line 88

def assert_number(name = nil)
  raise Sass::ScriptError.new("#{self} is not a number", name)
end

#assert_string(name = nil) ⇒ String

Returns:

Raises:



94
95
96
# File 'lib/sass/value.rb', line 94

def assert_string(name = nil)
  raise Sass::ScriptError.new("#{self} is not a string", name)
end

#at(index) ⇒ Value

Parameters:

  • index (Numeric)

Returns:



33
34
35
# File 'lib/sass/value.rb', line 33

def at(index)
  index < 1 && index >= -1 ? self : nil
end

#bracketed?::Boolean

Returns:

  • (::Boolean)


16
17
18
# File 'lib/sass/value.rb', line 16

def bracketed?
  false
end

#eql?(other) ⇒ ::Boolean

Returns:

  • (::Boolean)


21
22
23
# File 'lib/sass/value.rb', line 21

def eql?(other)
  self == other
end

#sass_index_to_array_index(sass_index, name = nil) ⇒ Integer

Parameters:

Returns:

  • (Integer)

Raises:



100
101
102
103
104
105
106
107
108
109
# File 'lib/sass/value.rb', line 100

def sass_index_to_array_index(sass_index, name = nil)
  index = sass_index.assert_number(name).assert_integer(name)
  raise Sass::ScriptError.new('List index may not be 0', name) if index.zero?

  if index.abs > to_a_length
    raise Sass::ScriptError.new("Invalid index #{sass_index} for a list with #{to_a_length} elements", name)
  end

  index.negative? ? to_a_length + index : index - 1
end

#separator::String?

Returns:

  • (::String, nil)


11
12
13
# File 'lib/sass/value.rb', line 11

def separator
  nil
end

#to_aArray<Value>

Returns:



38
39
40
# File 'lib/sass/value.rb', line 38

def to_a
  [self]
end

#to_bool::Boolean

Returns:

  • (::Boolean)


43
44
45
# File 'lib/sass/value.rb', line 43

def to_bool
  true
end

#to_mapMap?

Returns:



48
49
50
# File 'lib/sass/value.rb', line 48

def to_map
  nil
end

#to_nilValue?

Returns:



53
54
55
# File 'lib/sass/value.rb', line 53

def to_nil
  self
end