Class: Luoma::BlockDrop

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

Instance Method Summary collapse

Methods inherited from Drop

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

Constructor Details

#initialize(block) ⇒ BlockDrop

(t_block) -> void

Parameters:

  • block (t_block)


6
7
8
9
# File 'lib/luoma/drops/block.rb', line 6

def initialize(block)
  super()
  @block = block
end

Instance Method Details

#render(context) ⇒ string

Parameters:

Returns:

  • (string)


23
24
25
26
27
28
29
30
31
# File 'lib/luoma/drops/block.rb', line 23

def render(context)
  buf = +""

  context.extends({}) do # For recursive block detection.
    Luoma.render_block(@block, context, buf)
  end

  buf
end

#to_primitive(hint, context) ⇒ Object

Signature:

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



12
13
14
15
16
17
18
19
20
21
# File 'lib/luoma/drops/block.rb', line 12

def to_primitive(hint, context)
  case hint
  when :numeric
    :nothing
  when :data, :string
    render(context)
  when :boolean
    true
  end
end