Class: Thunderbird::Mbox

Inherits:
Object
  • Object
show all
Defined in:
lib/thunderbird/mbox.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:) ⇒ Mbox

Returns a new instance of Mbox.



9
10
11
# File 'lib/thunderbird/mbox.rb', line 9

def initialize(path:)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/thunderbird/mbox.rb', line 7

def path
  @path
end

Instance Method Details

#each(&block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/thunderbird/mbox.rb', line 13

def each(&block)
  content = File.read(index_path)
  data = parser.data(content)
  messages = data.tables[MESSAGE_NAMESPACE]["1"]
  File.open(path) do |file|
    messages.each do |id, message_info|
      message_size = message_info["offlineMsgSize"]
      length = message_size.to_i(16)
      message = file.read(length)
      block.call(id, message)
    end
  end
end