Class: Net::IMAP::ResponseParser::Gmail

Inherits:
Net::IMAP::ResponseParser
  • Object
show all
Defined in:
lib/net/imap/response_parser/gmail.rb

Instance Method Summary collapse

Instance Method Details

#astring_listObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/net/imap/response_parser/gmail.rb', line 55

def astring_list
  result = []
  match(T_LPAR)
  while true
    token = lookahead
    case token.symbol
    when T_RPAR
      shift_token
      break
    when T_SPACE
      shift_token
    end
    result.push(astring)
  end
  return result
end

#label_dataObject



48
49
50
51
52
53
# File 'lib/net/imap/response_parser/gmail.rb', line 48

def label_data
  token = match(T_ATOM)
  name = token.value.upcase
  match(T_SPACE)
  return name, astring_list
end

#msg_att(n = nil) ⇒ Object



2
3
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
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/net/imap/response_parser/gmail.rb', line 2

def msg_att(n = nil)
  match(T_LPAR)
  attr = {}
  while true
    token = lookahead
    case token.symbol
    when T_RPAR
      shift_token
      break
    when T_SPACE
      shift_token
      next
    end
    case token.value
    when /\A(?:ENVELOPE)\z/ni
      name, val = envelope_data
    when /\A(?:FLAGS)\z/ni
      name, val = flags_data
    when /\A(?:INTERNALDATE)\z/ni
      name, val = internaldate_data
    when /\A(?:RFC822(?:\.HEADER|\.TEXT)?)\z/ni
      name, val = rfc822_text
    when /\A(?:RFC822\.SIZE)\z/ni
      name, val = rfc822_size
    when /\A(?:BODY(?:STRUCTURE)?)\z/ni
      name, val = body_data
    when /\A(?:UID)\z/ni
      name, val = uid_data
    when /\A(?:X-GM-LABELS)\z/ni
      name, val = label_data
    when /\A(?:X-GM-MSGID)\z/ni
      name, val = uid_data
    when /\A(?:X-GM-THRID)\z/ni
      name, val = uid_data
    else
      if n # Ruby >= 2.0.0
        parse_error("unknown attribute `%s' for {%d}", token.value, n)
      else # Ruby <= 1.9.3
        parse_error("unknown attribute `%s'", token.value)
      end
    end
    attr[name] = val
  end
  return attr
end