Class: Cuttlebone::Definition::Parser
- Inherits:
-
Object
- Object
- Cuttlebone::Definition::Parser
- Defined in:
- lib/cuttlebone/definition.rb
Instance Method Summary collapse
- #command(string_or_regexp, &block) ⇒ Object
- #description(text) ⇒ Object
-
#initialize(definition) ⇒ Parser
constructor
A new instance of Parser.
- #prompt(text = '', &block) ⇒ Object
Constructor Details
#initialize(definition) ⇒ Parser
Returns a new instance of Parser.
11 12 13 |
# File 'lib/cuttlebone/definition.rb', line 11 def initialize definition @definition = definition end |
Instance Method Details
#command(string_or_regexp, &block) ⇒ Object
15 16 17 18 19 |
# File 'lib/cuttlebone/definition.rb', line 15 def command string_or_regexp, &block @definition.commands << [ string_or_regexp, block, @last_description ] @last_description = nil self end |
#description(text) ⇒ Object
21 22 23 24 |
# File 'lib/cuttlebone/definition.rb', line 21 def description text @last_description = text self end |
#prompt(text = '', &block) ⇒ Object
26 27 28 |
# File 'lib/cuttlebone/definition.rb', line 26 def prompt text='', &block @definition.prompt = block_given? ? block : proc { text } end |