Class: Regenerate::PageComponent

Inherits:
Object
  • Object
show all
Defined in:
lib/regenerate/web-page.rb

Overview

A component, which includes a sequence of lines which make up the text of that component

Direct Known Subclasses

RubyCode, SetPageObjectClass, StaticHtml, TextVariable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePageComponent

Returns a new instance of PageComponent.



13
14
15
16
17
# File 'lib/regenerate/web-page.rb', line 13

def initialize
  @lines = []
  @text = nil # if text is nil, component is not yet finished
  @parentPage = nil
end

Instance Attribute Details

#parentPageObject

Returns the value of attribute parentPage.



11
12
13
# File 'lib/regenerate/web-page.rb', line 11

def parentPage
  @parentPage
end

#textObject (readonly)

Returns the value of attribute text.



10
11
12
# File 'lib/regenerate/web-page.rb', line 10

def text
  @text
end

Instance Method Details

#addLine(line) ⇒ Object



42
43
44
# File 'lib/regenerate/web-page.rb', line 42

def addLine(line)
  @lines << line
end

#addToParentPageObject



46
47
48
# File 'lib/regenerate/web-page.rb', line 46

def addToParentPage
  # default do nothing
end

#finishedObject



38
39
40
# File 'lib/regenerate/web-page.rb', line 38

def finished
  @text != nil
end

#finishTextObject



50
51
52
53
# File 'lib/regenerate/web-page.rb', line 50

def finishText
  @text = @lines.join("\n")
  addToParentPage
end

#initializeFromStartComment(parsedCommentLine) ⇒ Object



34
35
36
# File 'lib/regenerate/web-page.rb', line 34

def initializeFromStartComment(parsedCommentLine)
  # default do nothing
end

#processEndComment(parsedCommentLine) ⇒ Object



27
28
29
30
31
32
# File 'lib/regenerate/web-page.rb', line 27

def processEndComment(parsedCommentLine)
  finishText
  if parsedCommentLine.name != @startName
    raise ParseException.new("Name #{parsedCommentLine.name.inspect} in end comment doesn't match name #{@startName.inspect} in start comment.")
  end
end

#processStartComment(parsedCommentLine) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/regenerate/web-page.rb', line 19

def processStartComment(parsedCommentLine)
  @startName = parsedCommentLine.name
  initializeFromStartComment(parsedCommentLine)
  if parsedCommentLine.sectionEnd # section end in start comment line, so already finished
    finishText
  end
end