class MailParser::RFC2045::Scanner
Constants
- TOKEN_RE
Public Instance Methods
scan(&block)
click to toggle source
# File lib/mailparser/rfc2045/scanner.rb, line 10 def scan(&block) case @header_type when :MIME_VERSION scan_mime_version(&block) else scan_structured(&block) end end
scan_mime_version() { |:DIGIT, s| ... }
click to toggle source
# File lib/mailparser/rfc2045/scanner.rb, line 38 def scan_mime_version() until @ss.eos? case when s = @ss.scan(/\s*\(/) s << cfws(@ss) next when s = @ss.scan(/\s+/) next when s = @ss.scan(/\d+/) yield [:DIGIT, s] when s = @ss.scan(/./) yield [s, s] end end yield nil end
scan_structured() { |:QUOTED_STRING, s| ... }
click to toggle source
# File lib/mailparser/rfc2045/scanner.rb, line 19 def scan_structured() until @ss.eos? case when s = @ss.scan(/\s*\(/) s << cfws(@ss) next when s = @ss.scan(/\s+/) next when s = @ss.scan(/\"(\s*(\\[#{TEXT_RE}]|[#{QTEXT_RE}]))*\s*\"/o) yield [:QUOTED_STRING, s] when s = @ss.scan(/[#{TOKEN_RE}]+/o) yield [:TOKEN, s] when s = @ss.scan(/./) yield [s, s] end end yield nil end