Class: Twilio::Rails::Phone::Tree::After

Inherits:
Object
  • Object
show all
Defined in:
lib/twilio/rails/phone/tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ After

Returns a new instance of After.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/twilio/rails/phone/tree.rb', line 58

def initialize(args)
  case args
  when Symbol, String
    @prompt = args.to_sym
  when Proc
    @proc = args
  when Hash
    args = args.with_indifferent_access
    @prompt = args[:prompt]&.to_sym
    @hangup = !!args[:hangup]

    @messages = if args[:message].is_a?(Proc)
      args[:message]
    else
      Twilio::Rails::Phone::Tree::MessageSet.new(args[:message])
    end

    raise Twilio::Rails::Phone::InvalidTreeError, "cannot have both prompt: and hangup:" if @prompt && @hangup
    raise Twilio::Rails::Phone::InvalidTreeError, "must have either prompt: or hangup:" unless @prompt || @hangup
  else
    raise Twilio::Rails::Phone::InvalidTreeError, "cannot parse :after from #{args.inspect}"
  end
end

Instance Attribute Details

#messagesObject (readonly)

Returns the value of attribute messages.



56
57
58
# File 'lib/twilio/rails/phone/tree.rb', line 56

def messages
  @messages
end

#procObject (readonly)

Returns the value of attribute proc.



56
57
58
# File 'lib/twilio/rails/phone/tree.rb', line 56

def proc
  @proc
end

#promptObject (readonly)

Returns the value of attribute prompt.



56
57
58
# File 'lib/twilio/rails/phone/tree.rb', line 56

def prompt
  @prompt
end

Instance Method Details

#hangup?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/twilio/rails/phone/tree.rb', line 82

def hangup?
  !!@hangup
end