Class: Net::IMAP::ResponseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/dm-imap-adapter/net_imap_ext.rb

Instance Method Summary collapse

Instance Method Details

#resp_text_codeObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dm-imap-adapter/net_imap_ext.rb', line 4

def resp_text_code
  @lex_state = EXPR_BEG
  match(T_LBRA)
  token = match(T_ATOM)
  name = token.value.upcase
  case name
  when /\A(?:ALERT|PARSE|READ-ONLY|READ-WRITE|TRYCREATE|NOMODSEQ|CLOSED)\z/n
    result = Net::IMAP::ResponseCode.new(name, nil)
  when /\A(?:PERMANENTFLAGS)\z/n
    match(T_SPACE)
    result = Net::IMAP::ResponseCode.new(name, flag_list)
  when /\A(?:UIDVALIDITY|UIDNEXT|UNSEEN)\z/n
    match(T_SPACE)
    result = Net::IMAP::ResponseCode.new(name, number)
  else
    # match(T_SPACE)
    ### start new
    if match(T_SPACE, T_RBRA).symbol == T_RBRA
      @lex_state = EXPR_RTEXT
      return Net::IMAP::ResponseCode.new(name, nil)
    end
    ### end new
    @lex_state = EXPR_CTEXT
    token = match(T_TEXT)
    @lex_state = EXPR_BEG
    result = Net::IMAP::ResponseCode.new(name, token.value)
  end
  match(T_RBRA)
  @lex_state = EXPR_RTEXT
  return result
end