Class: PM::CodeChunk
- Inherits:
-
Object
- Object
- PM::CodeChunk
- Defined in:
- lib/patchmaster/code_chunk.rb
Overview
A CodeChunk holds a block of code (lambda, block, proc) and the text that created it as read in from a PatchMaster file.
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(block, text = nil) ⇒ CodeChunk
constructor
A new instance of CodeChunk.
- #run(*args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(block, text = nil) ⇒ CodeChunk
Returns a new instance of CodeChunk.
9 10 11 |
# File 'lib/patchmaster/code_chunk.rb', line 9 def initialize(block, text=nil) @block, @text = block, text end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
7 8 9 |
# File 'lib/patchmaster/code_chunk.rb', line 7 def block @block end |
#text ⇒ Object
Returns the value of attribute text.
7 8 9 |
# File 'lib/patchmaster/code_chunk.rb', line 7 def text @text end |
Instance Method Details
#run(*args) ⇒ Object
13 14 15 |
# File 'lib/patchmaster/code_chunk.rb', line 13 def run(*args) block.call(*args) end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/patchmaster/code_chunk.rb', line 17 def to_s "#<PM::CodeChunk block=#{block.inspect}, text=#{text.inspect}>" end |