Class: Ataru::CodeSample
- Inherits:
-
Object
- Object
- Ataru::CodeSample
- Defined in:
- lib/ataru/code_sample.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#file ⇒ Object
Returns the value of attribute file.
-
#line_number ⇒ Object
Returns the value of attribute line_number.
-
#prepared_code ⇒ Object
Returns the value of attribute prepared_code.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(code, file, line_number) ⇒ CodeSample
constructor
A new instance of CodeSample.
- #run(b) ⇒ Object
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
#code ⇒ Object
Returns the value of attribute code.
3 4 5 |
# File 'lib/ataru/code_sample.rb', line 3 def code @code end |
#file ⇒ Object
Returns the value of attribute file.
3 4 5 |
# File 'lib/ataru/code_sample.rb', line 3 def file @file end |
#line_number ⇒ Object
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_code ⇒ Object
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 |