Module: Card::Format::Nesting::Main

Included in:
Card::Format::Nesting
Defined in:
lib/card/format/nesting/main.rb

Overview

Handle the main nest

Instance Method Summary collapse

Instance Method Details

#already_mained?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
# File 'lib/card/format/nesting/main.rb', line 22

def already_mained?
  return true if @main || @already_main
  @already_main = true
  false
end

#main!Object



28
29
30
# File 'lib/card/format/nesting/main.rb', line 28

def main!
  @main = true
end

#main_nest(opts) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/card/format/nesting/main.rb', line 10

def main_nest opts
  wrap_main do
    with_nest_mode :normal do
      nest root.card, opts.merge(main_view: true, main: true)
    end
  end
end

#main_nest?(nest_name) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/card/format/nesting/main.rb', line 18

def main_nest? nest_name
  nest_name == "_main" && !root.already_mained?
end

#main_nest_optionsObject



32
33
34
35
36
37
# File 'lib/card/format/nesting/main.rb', line 32

def main_nest_options
  opts = root.main_opts || {}
  main_nest_size_opt opts
  main_nest_items_opt opts
  opts
end

#wrap_mainObject



6
7
8
# File 'lib/card/format/nesting/main.rb', line 6

def wrap_main
  yield # no wrapping in base format
end