Class: Sass::Script::Value::DeprecatedFalse

Inherits:
Bool
  • Object
show all
Defined in:
lib/sass/script/value/deprecated_false.rb

Overview

A SassScript object representing a false value that came from a call to index(). It will print deprecation warnings if it's used with ==.

Constant Summary

Constants inherited from Bool

Bool::FALSE, Bool::TRUE

Instance Attribute Summary

Attributes inherited from Bool

#value

Attributes inherited from Base

#options, #source_range, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Bool

#to_s

Methods inherited from Base

#==, #_perform, #assert_int!, #div, #eql?, #hash, #inspect, #minus, #null?, #plus, #separator, #single_eq, #to_a, #to_bool, #to_h, #to_i, #to_s, #unary_div, #unary_minus, #unary_not, #unary_plus

Constructor Details

#initialize(environment) ⇒ DeprecatedFalse

Returns a new instance of DeprecatedFalse.



11
12
13
14
15
16
17
18
# File 'lib/sass/script/value/deprecated_false.rb', line 11

def initialize(environment)
  @value = false
  @global_env = environment.global_env
  if (frame = environment.stack.frames.last)
    @filename = frame.filename
    @line = frame.line
  end
end

Class Method Details

.new(environment)



5
6
7
8
9
# File 'lib/sass/script/value/deprecated_false.rb', line 5

def self.new(environment)
  obj = allocate
  obj.send(:initialize, environment)
  obj
end

Instance Method Details

#eq(other)



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sass/script/value/deprecated_false.rb', line 20

def eq(other)
  if other.value == false && !warned?
    self.warned = true
    Sass::Util.sass_warn <<WARNING + @global_env.stack.to_s.gsub(/^/, '        ')
DEPRECATION WARNING: The return value of index() will change from "false" to
"null" in future versions of Sass. For compatibility, avoid using "== false" on
the return value. For example, instead of "@if index(...) == false", just write
"@if not index(...)".
WARNING
  end
  Bool.new(other.value == false)
end

#neq(other)



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/sass/script/value/deprecated_false.rb', line 33

def neq(other)
  if other.value.nil? && !warned?
    self.warned = true
    Sass::Util.sass_warn <<WARNING + @global_env.stack.to_s.gsub(/^/, '        ')
DEPRECATION WARNING: The return value of index() will change from "false" to
"null" in future versions of Sass. For compatibility, avoid using "!= null" on
the return value.
WARNING
  end
  Bool.new(other.value != false)
end