Class: MakesSense::DecisionTableDsl
- Inherits:
-
Object
- Object
- MakesSense::DecisionTableDsl
- Includes:
- Values
- Defined in:
- lib/makes_sense/decision_table.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#result_table ⇒ Object
readonly
Returns the value of attribute result_table.
Instance Method Summary collapse
- #arg(name) ⇒ Object
- #condition(name, type) ⇒ Object
-
#initialize ⇒ DecisionTableDsl
constructor
A new instance of DecisionTableDsl.
- #table(&block) ⇒ Object
Methods included from Values
Constructor Details
#initialize ⇒ DecisionTableDsl
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
#args ⇒ Object (readonly)
Returns the value of attribute args.
150 151 152 |
# File 'lib/makes_sense/decision_table.rb', line 150 def args @args end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
150 151 152 |
# File 'lib/makes_sense/decision_table.rb', line 150 def conditions @conditions end |
#result_table ⇒ Object (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 |