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.
149 150 151 152 153 |
# File 'lib/simplerubysteps/model.rb', line 149 def initialize(name) super @choices = [] @dict[:Type] = "Choice" end |
Instance Attribute Details
#choices ⇒ Object (readonly)
Returns the value of attribute choices.
147 148 149 |
# File 'lib/simplerubysteps/model.rb', line 147 def choices @choices end |
Instance Method Details
#add(item) ⇒ Object
155 156 157 |
# File 'lib/simplerubysteps/model.rb', line 155 def add(item) @choices.push item end |
#add_string_matches(var, match, state) ⇒ Object
159 160 161 162 163 164 |
# File 'lib/simplerubysteps/model.rb', line 159 def add_string_matches(var, match, state) add ChoiceItem.new({ :Variable => var, :StringMatches => match, }, state) end |
#default=(state) ⇒ Object
166 167 168 |
# File 'lib/simplerubysteps/model.rb', line 166 def default=(state) @dict[:Default] = (state.is_a? Symbol) ? state : state.name end |
#next=(state) ⇒ Object
170 171 172 |
# File 'lib/simplerubysteps/model.rb', line 170 def next=(state) self.default = state end |
#perform_action(output) ⇒ Object
180 181 182 183 184 |
# File 'lib/simplerubysteps/model.rb', line 180 def perform_action(output) @choices.each do |choice| choice.perform_action name, output end end |
#render ⇒ Object
174 175 176 177 178 |
# File 'lib/simplerubysteps/model.rb', line 174 def render dict = @dict.clone dict[:Choices] = @choices.map { |item| item.render } dict end |