Class: Cardigan::Command::RemoveTransitions
- Inherits:
-
Object
- Object
- Cardigan::Command::RemoveTransitions
- Defined in:
- lib/cardigan/command/remove_transitions.rb
Instance Attribute Summary collapse
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
- #execute(text = nil) ⇒ Object
-
#initialize(entry, io) ⇒ RemoveTransitions
constructor
A new instance of RemoveTransitions.
Constructor Details
#initialize(entry, io) ⇒ RemoveTransitions
Returns a new instance of RemoveTransitions.
6 7 8 9 10 |
# File 'lib/cardigan/command/remove_transitions.rb', line 6 def initialize entry, io @entry, @io = entry, io @usage = '<start status> [<subsequent status>]+' @help = 'Removes transitions from a starting status to a number of subsequent statuses' end |
Instance Attribute Details
#help ⇒ Object (readonly)
Returns the value of attribute help.
4 5 6 |
# File 'lib/cardigan/command/remove_transitions.rb', line 4 def help @help end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
4 5 6 |
# File 'lib/cardigan/command/remove_transitions.rb', line 4 def usage @usage end |
Instance Method Details
#execute(text = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cardigan/command/remove_transitions.rb', line 12 def execute text=nil unless text and !text.empty? @io.say 'missing required start status' return end name, *states = text.scan(/\w+/) if states.empty? @io.say 'missing required subsequent status' return end name, *states = text.scan(/\w+/) @entry[name] -= states end |