Module: Lab42::Literate::Extractor
Defined Under Namespace
Classes: Block
Constant Summary collapse
- START_EXTRACTION =
%r[\A \s* ``` ruby \s+ literate \s* (?<explicit_title> .*) ]x- STOP_EXTRACTION =
%r[\A \s* ``` \s* \z]x- ALTERNATE_EQ_FORM =
%r[\A (\s*) (.*) \s+ \#=> \s+ (.*) \z]x
Instance Method Summary collapse
Instance Method Details
#extract(from_lines) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/lab42/literate/extractor.rb', line 12 def extract from_lines initial = OpenStruct.new(state: :outside, blocks: []) from_lines .each_with_index .inject(initial){|acc, (line, lnb)| update(line, lnb, acc) } .blocks end |