Class: Mhtml::RootDocument

Inherits:
Document show all
Defined in:
lib/mhtml/root_document.rb

Constant Summary collapse

BOUNDARY_PREFIX =
'--'.freeze

Instance Attribute Summary collapse

Attributes inherited from Document

#body, #chunked, #encoding, #file_path, #headers, #is_base_64, #is_quoted_printable, #parser, #root_doc

Instance Method Summary collapse

Methods inherited from Document

#<<, #header, #on_body, #on_header, #relative_file_path

Constructor Details

#initialize(str = nil) ⇒ RootDocument

Returns a new instance of RootDocument.



7
8
9
10
# File 'lib/mhtml/root_document.rb', line 7

def initialize(str = nil)
  @sub_docs = []
  super(str)
end

Instance Attribute Details

#boundaryObject

Returns the value of attribute boundary.



5
6
7
# File 'lib/mhtml/root_document.rb', line 5

def boundary
  @boundary
end

#sub_docsObject

Returns the value of attribute sub_docs.



5
6
7
# File 'lib/mhtml/root_document.rb', line 5

def sub_docs
  @sub_docs
end

Instance Method Details

#==(other) ⇒ Object



12
13
14
# File 'lib/mhtml/root_document.rb', line 12

def ==(other)
  super(other) && @boundary == other.boundary && @sub_docs == other.sub_docs
end

#boundary_strObject



32
33
34
# File 'lib/mhtml/root_document.rb', line 32

def boundary_str
  "#{Mhtml::LINE_BREAK}#{BOUNDARY_PREFIX}#{@boundary}#{Mhtml::LINE_BREAK}"
end

#last_boundary_strObject



36
37
38
# File 'lib/mhtml/root_document.rb', line 36

def last_boundary_str
  "#{Mhtml::LINE_BREAK}#{BOUNDARY_PREFIX}#{@boundary}#{BOUNDARY_PREFIX}#{Mhtml::LINE_BREAK}"
end

#on_subdoc_beginObject



16
17
18
# File 'lib/mhtml/root_document.rb', line 16

def on_subdoc_begin
  @subdoc_begin_proc = Proc.new
end

#on_subdoc_bodyObject



24
25
26
# File 'lib/mhtml/root_document.rb', line 24

def on_subdoc_body
  @subdoc_body_proc = Proc.new
end

#on_subdoc_completeObject



28
29
30
# File 'lib/mhtml/root_document.rb', line 28

def on_subdoc_complete
  @subdoc_complete_proc = Proc.new
end

#on_subdoc_headerObject



20
21
22
# File 'lib/mhtml/root_document.rb', line 20

def on_subdoc_header
  @subdoc_header_proc = Proc.new
end

#to_sObject

for testing only = no spec implemented



41
42
43
44
45
# File 'lib/mhtml/root_document.rb', line 41

def to_s
  doc_sep = Mhtml::DOUBLE_LINE_BREAK + BOUNDARY_PREFIX + @boundary + 
    Mhtml::LINE_BREAK
  super + doc_sep + @sub_docs.join(doc_sep)
end