Class: Sass::Value::Function

Inherits:
Object
  • Object
show all
Includes:
Sass::Value
Defined in:
lib/sass/value/function.rb

Overview

Sass’s function type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Sass::Value

#[], #assert_boolean, #assert_calculation, #assert_color, #assert_map, #assert_mixin, #assert_number, #assert_string, #at, #bracketed?, #eql?, #sass_index_to_array_index, #separator, #to_a, #to_bool, #to_map, #to_nil

Constructor Details

#initialize(signature, &callback) ⇒ Function

Returns a new instance of Function.

Parameters:

  • signature (::String)
  • callback (Proc)


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

def initialize(signature, &callback)
  @signature = signature.freeze
  @callback = callback.freeze
end

Instance Attribute Details

#callbackProc? (readonly)

Returns:

  • (Proc, nil)


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

def callback
  @callback
end

#signature::String? (readonly)

Returns:

  • (::String, nil)


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

def signature
  @signature
end

Instance Method Details

#==(other) ⇒ ::Boolean

Returns:

  • (::Boolean)


31
32
33
34
35
36
37
38
39
# File 'lib/sass/value/function.rb', line 31

def ==(other)
  return false unless other.is_a?(Sass::Value::Function)

  if defined?(@id)
    other.compile_context == compile_context && other.id == id
  else
    other.signature == signature && other.callback == callback
  end
end

#assert_function(_name = nil) ⇒ Function

Returns:



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

def assert_function(_name = nil)
  self
end

#hashInteger

Returns:

  • (Integer)


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

def hash
  @hash ||= defined?(@id) ? [compile_context, id].hash : [signature, callback].hash
end