Class: RastSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/rast/rast_spec.rb

Overview

CaseFixture.java, containing an actual and specific combination of variables.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description: '', variables: {}, rule: nil, default_outcome: '') ⇒ RastSpec

Returns a new instance of RastSpec.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rast/rast_spec.rb', line 15

def initialize(
  description: '',
  variables: {},
  rule: nil,
  default_outcome: ''
)
  @description = description
  @variables = variables
  @pair = {}
  @pair_reversed = {}
  @rule = rule
  @exclude_clause = nil
  @include_clause = nil
  @default_outcome = default_outcome
end

Instance Attribute Details

#convertersObject (readonly)

token_converter is the mapping of a variable token to a converter converters is a list of converters used via positional tokens.



9
10
11
# File 'lib/rast/rast_spec.rb', line 9

def converters
  @converters
end

#default_outcomeObject (readonly)

token_converter is the mapping of a variable token to a converter converters is a list of converters used via positional tokens.



9
10
11
# File 'lib/rast/rast_spec.rb', line 9

def default_outcome
  @default_outcome
end

#descriptionObject (readonly)

token_converter is the mapping of a variable token to a converter converters is a list of converters used via positional tokens.



9
10
11
# File 'lib/rast/rast_spec.rb', line 9

def description
  @description
end

#excludeObject

Returns the value of attribute exclude.



13
14
15
# File 'lib/rast/rast_spec.rb', line 13

def exclude
  @exclude
end

#exclude_clauseObject (readonly)

token_converter is the mapping of a variable token to a converter converters is a list of converters used via positional tokens.



9
10
11
# File 'lib/rast/rast_spec.rb', line 9

def exclude_clause
  @exclude_clause
end

#include_clauseObject (readonly)

token_converter is the mapping of a variable token to a converter converters is a list of converters used via positional tokens.



9
10
11
# File 'lib/rast/rast_spec.rb', line 9

def include_clause
  @include_clause
end

#pairObject (readonly)

token_converter is the mapping of a variable token to a converter converters is a list of converters used via positional tokens.



9
10
11
# File 'lib/rast/rast_spec.rb', line 9

def pair
  @pair
end

#pair_reversedObject (readonly)

token_converter is the mapping of a variable token to a converter converters is a list of converters used via positional tokens.



9
10
11
# File 'lib/rast/rast_spec.rb', line 9

def pair_reversed
  @pair_reversed
end

#ruleObject (readonly)

token_converter is the mapping of a variable token to a converter converters is a list of converters used via positional tokens.



9
10
11
# File 'lib/rast/rast_spec.rb', line 9

def rule
  @rule
end

#token_converterObject (readonly)

token_converter is the mapping of a variable token to a converter converters is a list of converters used via positional tokens.



9
10
11
# File 'lib/rast/rast_spec.rb', line 9

def token_converter
  @token_converter
end

#variablesObject (readonly)

token_converter is the mapping of a variable token to a converter converters is a list of converters used via positional tokens.



9
10
11
# File 'lib/rast/rast_spec.rb', line 9

def variables
  @variables
end

Instance Method Details

#init_converters(converters: []) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rast/rast_spec.rb', line 39

def init_converters(converters: [])
  @converters = converters
  @token_converter = {}

  @variables.keys.each_with_index do |key, index|
    @variables[key].each do |element|
      converter = RuleEvaluator::DEFAULT_CONVERT_HASH[element.class] ||
                  converters[index]
      @token_converter[element.to_s] = converter
    end
  end

  self
end

#init_exclusion(exclude_clause) ⇒ Object



54
55
56
57
# File 'lib/rast/rast_spec.rb', line 54

def init_exclusion(exclude_clause)
  @exclude_clause = exclude_clause
  self
end

#init_inclusion(include_clause) ⇒ Object



59
60
61
62
# File 'lib/rast/rast_spec.rb', line 59

def init_inclusion(include_clause)
  @include_clause = include_clause
  self
end

#init_pair(pair_config: {}) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/rast/rast_spec.rb', line 31

def init_pair(pair_config: {})
  @pair[pair_config.keys.first.to_s] = pair_config.values.first.to_s

  array = [@pair.to_a.first.reverse].first
  @pair_reversed = { array.first.to_s => array.last }
  self
end