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)


24
25
26
27
28
29
# File 'lib/card/format/nesting/main.rb', line 24

def already_mained?
  return true if @main || @already_main

  @already_main = true
  false
end

#main!Object



31
32
33
# File 'lib/card/format/nesting/main.rb', line 31

def main!
  @main = true
end

#main_nest(opts = {}) ⇒ Object



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

def main_nest opts={}
  with_nest_mode :normal do
    if block_given?
      block.call
    else
      nest root.card, opts.merge(main_view: true, main: true)
    end
  end
end

#main_nest?(nest_name) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/card/format/nesting/main.rb', line 20

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

#main_nest_optionsObject

view=edit&items=closed



36
37
38
39
40
41
# File 'lib/card/format/nesting/main.rb', line 36

def main_nest_options
  opts = inherit(: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