Class: Mutant::Meta::Example::DSL Private

Inherits:
Object
  • Object
show all
Includes:
AST::Sexp
Defined in:
lib/mutant/meta/example/dsl.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Example DSL

API:

  • private

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, types) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize object

API:

  • private



27
28
29
30
31
32
33
# File 'lib/mutant/meta/example/dsl.rb', line 27

def initialize(file, types)
  @expected = []
  @file     = file
  @lvars    = []
  @source   = nil
  @types    = types
end

Class Method Details

.call(file, types, block) ⇒ Example

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run DSL on block

Parameters:

Returns:

API:

  • private



16
17
18
19
20
# File 'lib/mutant/meta/example/dsl.rb', line 16

def self.call(file, types, block)
  instance = new(file, types)
  instance.instance_eval(&block)
  instance.example
end

Instance Method Details

#declare_lvar(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Declare a local variable

Parameters:

API:

  • private



56
57
58
# File 'lib/mutant/meta/example/dsl.rb', line 56

def declare_lvar(name)
  @lvars << name
end

#exampleExample

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Example captured by DSL

Returns:

Raises:

  • in case example cannot be build

API:

  • private



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mutant/meta/example/dsl.rb', line 41

def example
  fail 'source not defined' unless @source
  Example.new(
    expected:        @expected,
    file:            @file,
    lvars:           @lvars,
    node:            @node,
    original_source: @source,
    types:           @types
  )
end