Class: Vagrant::Util::Mime::Entity
- Inherits:
-
Object
- Object
- Vagrant::Util::Mime::Entity
- Defined in:
- lib/vagrant/util/mime.rb
Instance Attribute Summary collapse
-
#content ⇒ String
readonly
Entity content.
-
#content_type ⇒ String
readonly
Type of the entity content.
-
#disposition ⇒ String
Content disposition.
Instance Method Summary collapse
-
#initialize(content, content_type) ⇒ Entity
constructor
A new instance of Entity.
-
#to_s ⇒ String
Output MimeEntity as a string.
Constructor Details
#initialize(content, content_type) ⇒ Entity
Returns a new instance of Entity.
71 72 73 74 75 76 77 78 |
# File 'lib/vagrant/util/mime.rb', line 71 def initialize(content, content_type) if !MIME::Types.include?(content_type) MIME::Types.add(MIME::Type.new(content_type)) end @content = content @content_type = MIME::Types[content_type].first @content_id = "#{Time.now.to_i}@#{SecureRandom.alphanumeric(24)}.local" end |
Instance Attribute Details
#content ⇒ String (readonly)
Returns entity content.
61 62 63 |
# File 'lib/vagrant/util/mime.rb', line 61 def content @content end |
#content_type ⇒ String (readonly)
Returns type of the entity content.
64 65 66 |
# File 'lib/vagrant/util/mime.rb', line 64 def content_type @content_type end |
#disposition ⇒ String
Returns content disposition.
67 68 69 |
# File 'lib/vagrant/util/mime.rb', line 67 def disposition @disposition end |
Instance Method Details
#to_s ⇒ String
Output MimeEntity as a string
83 84 85 86 87 88 89 90 91 |
# File 'lib/vagrant/util/mime.rb', line 83 def to_s output_string = "Content-ID: <#{@content_id}>\n" output_string += "Content-Type: #{@content_type}\n" if disposition output_string += "Content-Disposition: #{@disposition}\n" end output_string += "\n#{content}" output_string end |