Module: Sass::Value

Included in:
Boolean, Calculation, Color, Function, List, Map, Mixin, 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/mixin.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/calculation.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, Calculation, Color, Function, List, Map, Mixin, Null, Number, String

Instance Method Summary collapse

Instance Method Details

#[](index) ⇒ Value

Parameters:

  • index (Numeric)

Returns:



25
26
27
# File 'lib/sass/value.rb', line 25

def [](index)
  at(index)
end

#assert_boolean(name = nil) ⇒ Boolean

Returns:

Raises:



57
58
59
# File 'lib/sass/value.rb', line 57

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

#assert_calculation(name = nil) ⇒ Calculation

Returns:

Raises:



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

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

#assert_color(name = nil) ⇒ Color

Returns:

Raises:



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

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

#assert_function(name = nil) ⇒ Function

Returns:

Raises:



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

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

#assert_map(name = nil) ⇒ Map

Returns:

Raises:



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

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

#assert_mixin(name = nil) ⇒ Mixin

Returns:

Raises:



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

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

#assert_number(name = nil) ⇒ Number

Returns:

Raises:



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

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

#assert_string(name = nil) ⇒ String

Returns:

Raises:



99
100
101
# File 'lib/sass/value.rb', line 99

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

#at(index) ⇒ Value

Parameters:

  • index (Numeric)

Returns:



31
32
33
# File 'lib/sass/value.rb', line 31

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

#bracketed?::Boolean

Returns:

  • (::Boolean)


14
15
16
# File 'lib/sass/value.rb', line 14

def bracketed?
  false
end

#eql?(other) ⇒ ::Boolean

Returns:

  • (::Boolean)


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

def eql?(other)
  self == other
end

#sass_index_to_array_index(sass_index, name = nil) ⇒ Integer

Parameters:

Returns:

  • (Integer)

Raises:



105
106
107
108
109
110
111
112
113
114
# File 'lib/sass/value.rb', line 105

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)


9
10
11
# File 'lib/sass/value.rb', line 9

def separator
  nil
end

#to_aArray<Value>

Returns:



36
37
38
# File 'lib/sass/value.rb', line 36

def to_a
  [self]
end

#to_bool::Boolean

Returns:

  • (::Boolean)


41
42
43
# File 'lib/sass/value.rb', line 41

def to_bool
  true
end

#to_mapMap?

Returns:



46
47
48
# File 'lib/sass/value.rb', line 46

def to_map
  nil
end

#to_nilValue?

Returns:



51
52
53
# File 'lib/sass/value.rb', line 51

def to_nil
  self
end