Class: Mail::Part
- Inherits:
-
Object
- Object
- Mail::Part
- Defined in:
- lib/mail/part.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#header ⇒ Object
readonly
Returns the value of attribute header.
Instance Method Summary collapse
- #content ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(options) ⇒ Part
constructor
A new instance of Part.
- #to_s ⇒ Object
Constructor Details
#initialize(options) ⇒ Part
Returns a new instance of Part.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mail/part.rb', line 5 def initialize() if .kind_of?(String) @part_str = set_header() elsif .kind_of?(Hash) @part_str = [:content] @header = Header.new(:content_type => [:content_type]) else @header = Header.new end end |
Instance Attribute Details
#header ⇒ Object (readonly)
Returns the value of attribute header.
3 4 5 |
# File 'lib/mail/part.rb', line 3 def header @header end |
Instance Method Details
#content ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mail/part.rb', line 25 def content buffer = String.new body_found = false @part_str.each_line do |line| if body_found buffer << line end body_found = true if !body_found && line.strip.empty? end return buffer end |
#empty? ⇒ Boolean
21 22 23 |
# File 'lib/mail/part.rb', line 21 def empty? @part_str.empty? end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/mail/part.rb', line 17 def to_s @part_str end |