Class: Simplerubysteps::ChoiceItem

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dict = {}, state = nil) ⇒ ChoiceItem

Returns a new instance of ChoiceItem.



127
128
129
130
# File 'lib/simplerubysteps.rb', line 127

def initialize(dict = {}, state = nil)
  @dict = dict
  self.next = state if state
end

Instance Attribute Details

#implicit_condition_blockObject

Returns the value of attribute implicit_condition_block.



125
126
127
# File 'lib/simplerubysteps.rb', line 125

def implicit_condition_block
  @implicit_condition_block
end

Instance Method Details

#next=(state) ⇒ Object



132
133
134
# File 'lib/simplerubysteps.rb', line 132

def next=(state)
  @dict[:Next] = (state.is_a? Symbol) ? state : state.name
end

#perform_action(choice_name, output) ⇒ Object



140
141
142
143
144
# File 'lib/simplerubysteps.rb', line 140

def perform_action(choice_name, output)
  if @implicit_condition_block
    output["#{choice_name}_#{@dict[:Next]}"] = @implicit_condition_block.call(output) ? "yes" : "no"
  end
end

#renderObject



136
137
138
# File 'lib/simplerubysteps.rb', line 136

def render
  @dict
end