Class: Punchblock::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/punchblock/dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, call_id, queue) ⇒ DSL

:nodoc:



7
8
9
# File 'lib/punchblock/dsl.rb', line 7

def initialize(client, call_id, queue) # :nodoc:
  @client, @call_id, @queue = client, call_id, queue
end

Instance Method Details

#acceptObject

:nodoc:



11
12
13
# File 'lib/punchblock/dsl.rb', line 11

def accept # :nodoc:
  write Command::Accept.new
end

#answerObject

:nodoc:



15
16
17
# File 'lib/punchblock/dsl.rb', line 15

def answer # :nodoc:
  write Command::Answer.new
end

#hangupObject

:nodoc:



19
20
21
# File 'lib/punchblock/dsl.rb', line 19

def hangup # :nodoc:
  write Command::Hangup.new
end

#record(options = {}) ⇒ Object



31
32
33
# File 'lib/punchblock/dsl.rb', line 31

def record(options = {})
  write Component::Record.new(options)
end

#redirect(dest) ⇒ Object

:nodoc:



27
28
29
# File 'lib/punchblock/dsl.rb', line 27

def redirect(dest) # :nodoc:
  write Command::Redirect.new(:to => dest)
end

#reject(reason = nil) ⇒ Object

:nodoc:



23
24
25
# File 'lib/punchblock/dsl.rb', line 23

def reject(reason = nil) # :nodoc:
  write Command::Reject.new(:reason => reason)
end

#say(string, type = :text) ⇒ Object

:nodoc:



35
36
37
38
39
# File 'lib/punchblock/dsl.rb', line 35

def say(string, type = :text) # :nodoc:
  component = Component::Tropo::Say.new(type => string)
  write component
  component.complete_event.resource
end

#write(command) ⇒ Object

:nodoc:



41
42
43
# File 'lib/punchblock/dsl.rb', line 41

def write(command) # :nodoc:
  @client.execute_command command, :call_id => @call_id, :async => false
end