Class: PseudoHiki::BlockParser::NonNestedBlockLeaf

Inherits:
BlockLeaf
  • Object
show all
Includes:
TreeStack::Mergeable
Defined in:
lib/pseudohiki/blockparser.rb

Instance Attribute Summary

Attributes inherited from BlockLeaf

#level, #node_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BlockLeaf

#block, #head_re, #parse_leafs, #push_block, #under_appropriate_block?, with_depth?

Class Method Details

.create(line) ⇒ Object



95
96
97
98
# File 'lib/pseudohiki/blockparser.rb', line 95

def self.create(line)
  line = line.sub(head_re, "".freeze) if head_re
  new.tap {|leaf| leaf.push line }
end

Instance Method Details

#push_self(stack) ⇒ Object



100
101
102
103
104
105
106
107
# File 'lib/pseudohiki/blockparser.rb', line 100

def push_self(stack)
  push_block(stack) unless under_appropriate_block?(stack)
  if stack.last_leaf.kind_of? self.class
    stack.last_leaf.merge(self)
  else
    super(stack)
  end
end