Class: Cuttlebone::Definition::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/cuttlebone/definition.rb

Instance Method Summary collapse

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