module Speculations::Parser::State::Out

Public Instance Methods

parse(line, lnb, node, _ctxt) click to toggle source
# File lib/speculations/parser/state/out.rb, line 6
def parse line, lnb, node, _ctxt
  case
  when match = State.context_match(line)
    make_new_context(lnb: lnb, node: node, match: match)
  when match = State.maybe_example(line)
    [:candidate, node, match[:title]]
  when match = State.maybe_include(line)
    [:candidate, node, :inc]
  else
    [:out, node]
  end
end

Private Instance Methods

make_new_context(lnb:, match:, node:) click to toggle source
# File lib/speculations/parser/state/out.rb, line 21
def make_new_context(lnb:, match:, node:)
  level = match[:level].size
  new_parent = node.parent_of_level(level.pred)
  node = new_parent.new_context(title: match[:title], lnb: lnb, level: level)
  [:out, node]
end