Class: Mxrb::Dsl::DecisionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/mxrb/dsl/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(condition) ⇒ DecisionBuilder

Returns a new instance of DecisionBuilder.



1618
1619
1620
1621
1622
1623
# File 'lib/mxrb/dsl/builder.rb', line 1618

def initialize(condition)
  @condition      = condition
  @true_branch    = []
  @false_branch   = []
  @branches       = {}
end

Instance Method Details

#on(value, &block) ⇒ Object



1625
1626
1627
1628
1629
1630
1631
1632
1633
# File 'lib/mxrb/dsl/builder.rb', line 1625

def on(value, &block)
  bb = BranchBuilder.new
  bb.instance_eval(&block) if block
  case value
  when true  then @true_branch  = bb.activities
  when false then @false_branch = bb.activities
  end
  @branches[value] = bb.activities
end

#to_hObject



1635
1636
1637
1638
1639
# File 'lib/mxrb/dsl/builder.rb', line 1635

def to_h
  { type: :decision, condition: @condition,
    true_branch: @true_branch, false_branch: @false_branch,
    branches: @branches }
end