Class: ExampleBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/matest/example_block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ ExampleBlock

Returns a new instance of ExampleBlock.



11
12
13
14
15
16
17
18
19
# File 'lib/matest/example_block.rb', line 11

def initialize(block)
  @block = block

  @code =  generate_code

  @sexp = Ripper::SexpBuilder.new(code).parse.last
  @assertion_sexp = @sexp.last
  @assertion = Sorcerer.source(assertion_sexp)
end

Instance Attribute Details

#assertionObject (readonly)

Returns the value of attribute assertion.



8
9
10
# File 'lib/matest/example_block.rb', line 8

def assertion
  @assertion
end

#assertion_sexpObject (readonly)

Returns the value of attribute assertion_sexp.



9
10
11
# File 'lib/matest/example_block.rb', line 9

def assertion_sexp
  @assertion_sexp
end

#blockObject (readonly)

Returns the value of attribute block.



5
6
7
# File 'lib/matest/example_block.rb', line 5

def block
  @block
end

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/matest/example_block.rb', line 6

def code
  @code
end

#sexpObject (readonly)

Returns the value of attribute sexp.



7
8
9
# File 'lib/matest/example_block.rb', line 7

def sexp
  @sexp
end

Instance Method Details

#callObject



21
22
23
# File 'lib/matest/example_block.rb', line 21

def call
  block.call
end

#source_locationObject



25
26
27
# File 'lib/matest/example_block.rb', line 25

def source_location
  block.source_location
end