class MIME::Content::Multipart::Base::Parser
Constants
- CRLF_ENDING_RGX
Public Class Methods
new(target)
click to toggle source
# File lib/safrano/multipart.rb, line 268 def initialize(target) @body_lines = [] @target = target @parts = [] @bound_rgx = /^--#{@target.boundary}\s*$/ @lastb_rgx = /^--#{@target.boundary}--\s*$/ end
Public Instance Methods
addline(line)
click to toggle source
# File lib/safrano/multipart.rb, line 319 def addline(line) @body_lines << line end
collect_part()
click to toggle source
# File lib/safrano/multipart.rb, line 305 def collect_part # according to the multipart RFC spec, the preceeding CRLF # belongs to the boundary # but because we are a CRLF line-based parser we need # to remove it from the end of the last body line return unless @body_lines # the last line ends up frozen --> chomp! fails # @body_lines.last.chomp!(CRLF) last_line = @body_lines.pop.chomp(CRLF) @body_lines.push last_line @parts << @body_lines end
first_part(line)
click to toggle source
# File lib/safrano/multipart.rb, line 286 def first_part(line) return unless @bound_rgx =~ line @body_lines = [] end
last_part(line)
click to toggle source
# File lib/safrano/multipart.rb, line 299 def last_part(line) return unless @lastb_rgx =~ line collect_part end
next_part(line)
click to toggle source
# File lib/safrano/multipart.rb, line 292 def next_part(line) return unless @bound_rgx =~ line collect_part @body_lines = [] end
parse(level: 0)
click to toggle source
# File lib/safrano/multipart.rb, line 276 def parse(level: 0) @target.content = @parts.map do |mlines| MIME::Media::Parser.new.parse_lines(mlines, level: level + 1) end @body_lines = @bound_rgx = @lastb_rgx = nil @parts = nil @target.level = level @target end