Class: Simplerubysteps::Choice
- Defined in:
- lib/simplerubysteps/model.rb
Instance Attribute Summary collapse
-
#choices ⇒ Object
readonly
Returns the value of attribute choices.
Attributes inherited from State
Instance Method Summary collapse
- #add(item) ⇒ Object
- #add_string_matches(var, match, state) ⇒ Object
- #default=(state) ⇒ Object
-
#initialize(name) ⇒ Choice
constructor
A new instance of Choice.
- #next=(state) ⇒ Object
- #perform_action(output) ⇒ Object
- #render ⇒ Object
Methods inherited from State
Constructor Details
#initialize(name) ⇒ Choice
Returns a new instance of Choice.
180 181 182 183 184 |
# File 'lib/simplerubysteps/model.rb', line 180 def initialize(name) super @choices = [] @dict[:Type] = "Choice" end |
Instance Attribute Details
#choices ⇒ Object (readonly)
Returns the value of attribute choices.
178 179 180 |
# File 'lib/simplerubysteps/model.rb', line 178 def choices @choices end |
Instance Method Details
#add(item) ⇒ Object
186 187 188 |
# File 'lib/simplerubysteps/model.rb', line 186 def add(item) @choices.push item end |
#add_string_matches(var, match, state) ⇒ Object
190 191 192 193 194 195 |
# File 'lib/simplerubysteps/model.rb', line 190 def add_string_matches(var, match, state) add ChoiceItem.new({ :Variable => var, :StringMatches => match, }, state) end |
#default=(state) ⇒ Object
197 198 199 |
# File 'lib/simplerubysteps/model.rb', line 197 def default=(state) @dict[:Default] = (state.is_a? Symbol) ? state : state.name end |
#next=(state) ⇒ Object
201 202 203 |
# File 'lib/simplerubysteps/model.rb', line 201 def next=(state) self.default = state end |
#perform_action(output) ⇒ Object
211 212 213 214 215 |
# File 'lib/simplerubysteps/model.rb', line 211 def perform_action(output) @choices.each do |choice| choice.perform_action name, output end end |
#render ⇒ Object
205 206 207 208 209 |
# File 'lib/simplerubysteps/model.rb', line 205 def render dict = @dict.clone dict[:Choices] = @choices.map { |item| item.render } dict end |