Class: Sisimai::Mail::Memory
- Inherits:
-
Object
- Object
- Sisimai::Mail::Memory
- Defined in:
- lib/sisimai/mail/memory.rb
Overview
Sisimai::Mail::Memory is a class for reading an email string
Instance Attribute Summary collapse
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#path ⇒ Object
readonly
:path [String] Fixed string “<MEMORY>” :size [Integer] data size of the email text :payload [Array] Entire bounce mail message :offset [Integer] Index of “:payload”.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#size ⇒ Object
readonly
:path [String] Fixed string “<MEMORY>” :size [Integer] data size of the email text :payload [Array] Entire bounce mail message :offset [Integer] Index of “:payload”.
Instance Method Summary collapse
-
#initialize(argv1) ⇒ Sisimai::Mail::Memory
constructor
Constructor of Sisimai::Mail::Memory.
-
#read ⇒ String
Memory reader, works as an iterator.
Constructor Details
#initialize(argv1) ⇒ Sisimai::Mail::Memory
Constructor of Sisimai::Mail::Memory
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sisimai/mail/memory.rb', line 16 def initialize(argv1) raise 'is not a String' if argv1.is_a?(::String) == false raise 'is empty' if argv1.empty? @path = '<MEMORY>' @size = argv1.size @payload = [] @offset = 0 if argv1.start_with?('From ') # UNIX mbox @payload = argv1.scrub().split(/^From /).map! { |e| e = 'From ' + e } @payload.shift else @payload = [argv1] end end |
Instance Attribute Details
#offset ⇒ Object
Returns the value of attribute offset.
10 11 12 |
# File 'lib/sisimai/mail/memory.rb', line 10 def offset @offset end |
#path ⇒ Object (readonly)
:path [String] Fixed string “<MEMORY>” :size [Integer] data size of the email text :payload [Array] Entire bounce mail message :offset [Integer] Index of “:payload”
9 10 11 |
# File 'lib/sisimai/mail/memory.rb', line 9 def path @path end |
#payload ⇒ Object
Returns the value of attribute payload.
10 11 12 |
# File 'lib/sisimai/mail/memory.rb', line 10 def payload @payload end |
#size ⇒ Object (readonly)
:path [String] Fixed string “<MEMORY>” :size [Integer] data size of the email text :payload [Array] Entire bounce mail message :offset [Integer] Index of “:payload”
9 10 11 |
# File 'lib/sisimai/mail/memory.rb', line 9 def size @size end |
Instance Method Details
#read ⇒ String
Memory reader, works as an iterator.
36 37 38 39 40 |
# File 'lib/sisimai/mail/memory.rb', line 36 def read return nil if self.payload.empty? self.offset += 1 return self.payload.shift end |