Class: RubyAMI::Lexer

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_ami/lexer.rb

Constant Summary

STANZA_BREAK =
"\r\n\r\n"
PROMPT =
/Asterisk Call Manager\/(\d+\.\d+)\r\n/
KEYVALUEPAIR =
/^([[[:alnum:]]-_ ]+): *(.*)\r\n/
FOLLOWSDELIMITER =
/\r?\n?--END COMMAND--\r\n\r\n/
SUCCESS =
/response: *success/i
PONG =
/response: *pong/i
EVENT =
/event: *(?<event_name>.*)?/i
ERROR =
/response: *error/i
FOLLOWS =
/response: *follows/i
SCANNER =
/.*?#{STANZA_BREAK}/m
HEADER_SLICE =
/.*\r\n/
IMMEDIATE_RESP =
/.*/
CLASSIFIER =
/((?<event>#{EVENT})|(?<success>#{SUCCESS})|(?<pong>#{PONG})|(?<follows>#{FOLLOWS})|(?<error>#{ERROR})|(?<immediate>#{IMMEDIATE_RESP})\r\n)\r\n/i

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delegate = nil) ⇒ Lexer



21
22
23
24
25
# File 'lib/ruby_ami/lexer.rb', line 21

def initialize(delegate = nil)
  @delegate = delegate
  @buffer = ""
  @ami_version = nil
end

Instance Attribute Details

#ami_versionObject

Returns the value of attribute ami_version



19
20
21
# File 'lib/ruby_ami/lexer.rb', line 19

def ami_version
  @ami_version
end

Instance Method Details

#<<(new_data) ⇒ Object



27
28
29
30
# File 'lib/ruby_ami/lexer.rb', line 27

def <<(new_data)
  @buffer << new_data
  parse_buffer
end