Class: GreenPepper::HtmlExampleFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/greenpepper/factory/htmlexamplefactory.rb

Instance Method Summary collapse

Constructor Details

#initialize(factories = []) ⇒ HtmlExampleFactory

Returns a new instance of HtmlExampleFactory.



13
14
15
16
17
18
19
20
# File 'lib/greenpepper/factory/htmlexamplefactory.rb', line 13

def initialize(factories = [])
  @factories = factories
  @table_included = false
  @current_table = 0
  @current_factory = nil
  @more_table = nil
  @content = nil
end

Instance Method Details

#build_exampleObject



43
44
45
46
47
# File 'lib/greenpepper/factory/htmlexamplefactory.rb', line 43

def build_example
    ex = @current_factory.create_example(@content)
    @table_included = false
    ex
end

#need_more_content?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/greenpepper/factory/htmlexamplefactory.rb', line 39

def need_more_content?
  return @more_table
end

#push_content(table) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/greenpepper/factory/htmlexamplefactory.rb', line 22

def push_content(table)
  if @table_included == false
    @more_table = true
    @table_included = true
    @current_factory = @factories.find{ |f| f.support? table }
    @current_factory = UnknownExampleFactory.new if @current_factory.nil?
    @content = Table.new
  end
  
  @content.merge_with table
  @current_table += 1
  if @current_factory.last_table?(table)
    @more_table = false
  end
  @content
end