Class: Luoma::FalsyStrictUndefinedDrop

Inherits:
StrictUndefinedDrop show all
Defined in:
lib/luoma/drops/undefined.rb,
sig/luoma/drops/undefined.rbs

Overview

An "undefined" type that can be tested for truthiness and compared to other objects without raising an error.

Instance Method Summary collapse

Methods inherited from StrictUndefinedDrop

#contains?, #each, #error, #fetch, #gt?, #length, #lt?, #render, #slice, #to_s

Methods inherited from UndefinedDrop

#fetch, #initialize

Methods inherited from Drop

#contains?, #each, #fetch, #gt?, #length, #lt?, #render, #slice, #to_a, #to_s

Constructor Details

This class inherits a constructor from Luoma::UndefinedDrop

Instance Method Details

#eq?(obj, context) ⇒ Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/luoma/drops/undefined.rb', line 107

def eq?(obj, context)
  context.env.nothing?(obj)
end

#key?(obj, context) ⇒ Boolean

Returns:

  • (Boolean)


115
116
117
# File 'lib/luoma/drops/undefined.rb', line 115

def key?(obj, context)
  false
end

#to_primitive(hint, context) ⇒ Object



111
112
113
# File 'lib/luoma/drops/undefined.rb', line 111

def to_primitive(hint, context)
  hint == :boolean ? false : error
end