Class: Regenerate::RubyCode
- Inherits:
-
PageComponent
- Object
- PageComponent
- Regenerate::RubyCode
- Defined in:
- lib/regenerate/web-page.rb
Overview
A page component consisting of Ruby code which is to be evaluated in the context of the object that defines the page Defined by start line “<!– [ruby” and end line “ruby] –>”.
Instance Attribute Summary collapse
-
#lineNumber ⇒ Object
readonly
The line number, which matters for code evaluation so that Ruby can populate stack traces correctly.
Attributes inherited from PageComponent
Instance Method Summary collapse
-
#addToParentPage ⇒ Object
Add to parent page, which requires adding to the page’s list of Ruby page components (which will all get executed at some later stage).
-
#initialize(lineNumber) ⇒ RubyCode
constructor
Initialise this page component, additionally initialising the line number.
-
#output(showSource = true) ⇒ Object
Output this page component in a form that would be reparsed back into the same page component.
Methods inherited from PageComponent
#addLine, #finishText, #finished, #initializeFromStartComment, #processEndComment, #processStartComment
Constructor Details
#initialize(lineNumber) ⇒ RubyCode
Initialise this page component, additionally initialising the line number
89 90 91 92 |
# File 'lib/regenerate/web-page.rb', line 89 def initialize(lineNumber) super() @lineNumber = lineNumber end |
Instance Attribute Details
#lineNumber ⇒ Object (readonly)
The line number, which matters for code evaluation so that Ruby can populate stack traces correctly
86 87 88 |
# File 'lib/regenerate/web-page.rb', line 86 def lineNumber @lineNumber end |
Instance Method Details
#addToParentPage ⇒ Object
Add to parent page, which requires adding to the page’s list of Ruby page components (which will all get executed at some later stage)
105 106 107 |
# File 'lib/regenerate/web-page.rb', line 105 def addToParentPage @parentPage.addRubyComponent(self) end |
#output(showSource = true) ⇒ Object
Output this page component in a form that would be reparsed back into the same page component
95 96 97 98 99 100 101 |
# File 'lib/regenerate/web-page.rb', line 95 def output(showSource = true) if showSource "<!-- [ruby\n#{text}\nruby] -->\n" else "" end end |