Class: Luoma::UndefinedDrop

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

Overview

The default and base "undefined" type.

Direct Known Subclasses

StrictUndefinedDrop

Instance Method Summary collapse

Methods inherited from Drop

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

Constructor Details

#initialize(path, token, source, template_name) ⇒ UndefinedDrop

(String, t_token, String, String) -> void

Parameters:

  • path (String)
  • token (t_token)
  • source (String)
  • template_name (String)


9
10
11
12
13
14
15
# File 'lib/luoma/drops/undefined.rb', line 9

def initialize(path, token, source, template_name)
  super()
  @path = path
  @token = token
  @source = source
  @template_name = template_name
end

Instance Method Details

#eq?(obj, context) ⇒ Boolean

(untyped, RenderContext) -> bool

Parameters:

Returns:

  • (Boolean)


23
24
25
# File 'lib/luoma/drops/undefined.rb', line 23

def eq?(obj, context)
  obj.is_a?(UndefinedDrop)
end

#fetch(name, context, default: :nothing) ⇒ Object

Signature:

  • (String, RenderContext) -> untyped



18
19
20
# File 'lib/luoma/drops/undefined.rb', line 18

def fetch(name, context, default: :nothing)
  self
end

#to_primitive(hint, context) ⇒ Object

Signature:

  • (:data | :numeric | :string | :boolean, RenderContext) -> untyped



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/luoma/drops/undefined.rb', line 28

def to_primitive(hint, context)
  case hint
  when :data
    nil
  when :numeric
    :nothing
  when :string
    ""
  when :boolean
    false
  end
end