Class: PM::CodeChunk

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#blockObject

Returns the value of attribute block.



7
8
9
# File 'lib/patchmaster/code_chunk.rb', line 7

def block
  @block
end

#textObject

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_sObject



17
18
19
# File 'lib/patchmaster/code_chunk.rb', line 17

def to_s
  "#<PM::CodeChunk block=#{block.inspect}, text=#{text.inspect}>"
end