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