Class: MakesSense::DecisionTableDsl

Inherits:
Object
  • Object
show all
Includes:
Values
Defined in:
lib/makes_sense/decision_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Values

#any, #f, #t

Constructor Details

#initializeDecisionTableDsl

Returns a new instance of DecisionTableDsl.



152
153
154
155
156
# File 'lib/makes_sense/decision_table.rb', line 152

def initialize
  @args = []
  @conditions = []
  @result_table = nil
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



150
151
152
# File 'lib/makes_sense/decision_table.rb', line 150

def args
  @args
end

#conditionsObject (readonly)

Returns the value of attribute conditions.



150
151
152
# File 'lib/makes_sense/decision_table.rb', line 150

def conditions
  @conditions
end

#result_tableObject (readonly)

Returns the value of attribute result_table.



150
151
152
# File 'lib/makes_sense/decision_table.rb', line 150

def result_table
  @result_table
end

Instance Method Details

#arg(name) ⇒ Object



158
159
160
# File 'lib/makes_sense/decision_table.rb', line 158

def arg(name)
  @args << name
end

#condition(name, type) ⇒ Object



162
163
164
165
166
167
168
169
# File 'lib/makes_sense/decision_table.rb', line 162

def condition(name, type)
  values =
    case type
    when :bool then [t, f]
    end

  @conditions << Condition.new(name, values)
end

#table(&block) ⇒ Object



171
172
173
174
175
176
# File 'lib/makes_sense/decision_table.rb', line 171

def table(&block)
  result_table = ResultTable.new([])
  dsl = ResultTableDsl.new(result_table)
  dsl.instance_eval(&block)
  @result_table = result_table
end