class Asciidoctor::AbstractBlock

def <<(block)

Returns nothing.

# => ["p1", "p2"]
block.blocks
block << Block.new(block, :paragraph, 'p2')
block << Block.new(block, :paragraph, 'p1')

block = Block.new(parent, :preamble)

Examples

block - The new child block.

Public: Append a content block to this block's list of blocks.
def <<(block)
  if block.is_a?(Asciidoctor::Section)
    assign_index(block)
  end
  @blocks << block
end

def [](i)

=> "bar"
section[1]
section << 'bar'
section << 'foo'

section = Section.new

i - The Integer array index number.

Public: Get the element at i in the array of blocks.
def [](i)
  @blocks[i]
end

def assign_index(section)

returns nothing

Block (in document order)
Assign the next index of this section within the parent

Internal: Assign the next index (0-based) to this section
def assign_index(section)
  section.index = @next_section_index
  @next_section_index += 1
end

def blocks?

that should be the option 'sectionbody'
whether this Block *can* have block content
TODO we still need another method that answers
--

returns Whether this Block has block content

Public: Determine whether this Block contains block content
def blocks?
  !blocks.empty?
end

def clear_blocks

=> []
section.blocks
section.clear_blocks
=> ["foo", "bar"]
section.blocks
section << 'bar'
section << 'foo'

section = Section.new

Public: Clear this Block's list of blocks.
def clear_blocks
  @blocks = []
end

def delete_at(i)

=> ["foo"]
section.blocks

=> "bar"
section.delete_at(1)
section << 'bar'
section << 'foo'

section = Section.new

i - The Integer array index number.

returning that element or nil if i is out of range.
Public: Delete the element at i in the array of section blocks,
def delete_at(i)
  @blocks.delete_at(i)
end

def initialize(parent, context)

def initialize(parent, context)
  super(parent, context)
  @blocks = []
  @id = nil
  @title = nil
  if context == :document
    @level = 0
  elsif !parent.nil? && !self.is_a?(Asciidoctor::Section)
    @level = parent.level
  else
    @level = nil
  end
  @next_section_index = 0 
end

def insert(i, block)

["foo", "bar", "baz"]
section.blocks
section.insert(1, 'bar')
section << 'baz'
section << 'foo'

section = Section.new

val = The content block to insert.
i - The Integer array index number.

list of blocks.
Public: Insert a content block at the specified index in this block's
def insert(i, block)
  @blocks.insert(i, block)
end

def reindex_sections

returns nothing

as it appears in document order.
and reassign the section 0-based index value to each Section
Walk the descendents of the current Document or Section

Internal: Reassign the section indexes
def reindex_sections
  @next_section_index = 0
  @blocks.each {|block|
    if block.is_a?(Asciidoctor::Section)
      assign_index(block)
      block.reindex_sections
    end
  }
end

def sections

returns an Array of Section objects

# => 1
section.sections.size
section << Block.new(section, :paragraph, 'paragraph 2')
section << Section.new(parent)
section << Block.new(section, :paragraph, 'paragraph 1')
section = Section.new(parent)

Examples

Only applies to Document and Section instances

Public: Get the Array of child Section objects
def sections
  @blocks.inject([]) {|collector, block|
    collector << block if block.is_a?(Asciidoctor::Section)
    collector
  }
end

def size

=> 2
section.size
section << 'bar'
section << 'foo'

=> 0
section.size

section = Section.new

Examples

Public: Get the Integer number of blocks in this block
def size
  @blocks.size
end

def title

Returns the String title of this Block

=> "Foo 3^ # :: Bar(1)"
block.title
block.title = "Foo 3^ # {two-colons} Bar(1)"

Examples

:specialcharacters, :quotes, :replacements, :macros, :attributes and :post_replacements

The following substitutions are applied to block and section titles:

Public: Get the String title of this Block with title substitions applied
def title
  # prevent substitutions from being applied multiple times
  if defined?(@subbed_title)
    @subbed_title
  elsif @title
    @subbed_title = apply_title_subs(@title)
  else
    @title
  end
end

def title?

variable is blank (nil or empty)
Public: A convenience method that indicates whether the title instance
def title?
  !@title.to_s.empty?
end