class Lab42::Literate::Extractor::Block

Attributes

lines[R]
start_lnb[R]
title[R]

Public Class Methods

new(start_lnb, title: '') click to toggle source
# File lib/lab42/literate/extractor/block.rb, line 31
def initialize start_lnb, title: ''
  @lines     = []
  @start_lnb = start_lnb
  @title     = title
end

Public Instance Methods

add_line(line) click to toggle source
# File lib/lab42/literate/extractor/block.rb, line 8
def add_line line
  lines << line
end
get_title(alternative) click to toggle source
# File lib/lab42/literate/extractor/block.rb, line 13
def get_title alternative
  title.empty? ?  alternative : title
end
given?() click to toggle source
# File lib/lab42/literate/extractor/block.rb, line 18
def given?
  parsed.children.first.children == [nil, :Given]
rescue
  false
end
range() click to toggle source
# File lib/lab42/literate/extractor/block.rb, line 24
def range
  start_lnb..(start_lnb.pred + lines.size)
end

Private Instance Methods

parsed() click to toggle source
# File lib/lab42/literate/extractor/block.rb, line 37
def parsed
   @__parsed__ ||= Parser::CurrentRuby.parse(lines.join("\n"))
end