Class: Ataru::CodeSample

Inherits:
Object
  • Object
show all
Defined in:
lib/ataru/code_sample.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, file, line_number) ⇒ CodeSample

Returns a new instance of CodeSample.



5
6
7
8
9
# File 'lib/ataru/code_sample.rb', line 5

def initialize(code, file, line_number)
  self.code = code
  self.file = file
  self.line_number = line_number
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



3
4
5
# File 'lib/ataru/code_sample.rb', line 3

def code
  @code
end

#fileObject

Returns the value of attribute file.



3
4
5
# File 'lib/ataru/code_sample.rb', line 3

def file
  @file
end

#line_numberObject

Returns the value of attribute line_number.



3
4
5
# File 'lib/ataru/code_sample.rb', line 3

def line_number
  @line_number
end

#prepared_codeObject

Returns the value of attribute prepared_code.



3
4
5
# File 'lib/ataru/code_sample.rb', line 3

def prepared_code
  @prepared_code
end

Instance Method Details

#==(other) ⇒ Object



11
12
13
14
15
16
# File 'lib/ataru/code_sample.rb', line 11

def ==(other)
  self.class == other.class &&
    self.file == other.file &&
    self.code == other.code &&
    self.line_number == other.line_number
end

#run(b) ⇒ Object



22
23
24
# File 'lib/ataru/code_sample.rb', line 22

def run(b)
  eval(self.prepared_code, b, self.file, self.line_number)
end