Class: Mu::Xtractr::Content
- Inherits:
-
Object
- Object
- Mu::Xtractr::Content
- Defined in:
- lib/mu/xtractr/content.rb
Overview
end
Instance Attribute Summary collapse
-
#body ⇒ Object
The actual body of the content (gunzip’d PDF file, for example).
-
#encoding ⇒ Object
The encoding (base64, gzip, deflate, etc) of this content.
-
#message ⇒ Object
readonly
The message from which this content was extracted.
-
#name ⇒ Object
The name of the content (like a jpeg or pdf file).
-
#type ⇒ Object
The mime type of this content.
Instance Method Summary collapse
-
#initialize(message) ⇒ Content
constructor
:nodoc:.
-
#inspect ⇒ Object
:nodoc:.
-
#save(filename = nil) ⇒ Object
Save the content to a file.
Constructor Details
#initialize(message) ⇒ Content
:nodoc:
44 45 46 47 48 49 |
# File 'lib/mu/xtractr/content.rb', line 44 def initialize # :nodoc: @name = "content.#{.stream.flow.id}.#{.index}" @type = 'application/unknown' @body = nil @message = end |
Instance Attribute Details
#body ⇒ Object
The actual body of the content (gunzip’d PDF file, for example)
42 43 44 |
# File 'lib/mu/xtractr/content.rb', line 42 def body @body end |
#encoding ⇒ Object
The encoding (base64, gzip, deflate, etc) of this content.
33 34 35 |
# File 'lib/mu/xtractr/content.rb', line 33 def encoding @encoding end |
#message ⇒ Object (readonly)
The message from which this content was extracted.
39 40 41 |
# File 'lib/mu/xtractr/content.rb', line 39 def @message end |
#name ⇒ Object
The name of the content (like a jpeg or pdf file).
30 31 32 |
# File 'lib/mu/xtractr/content.rb', line 30 def name @name end |
#type ⇒ Object
The mime type of this content.
36 37 38 |
# File 'lib/mu/xtractr/content.rb', line 36 def type @type end |
Instance Method Details
#inspect ⇒ Object
:nodoc:
62 63 64 65 |
# File 'lib/mu/xtractr/content.rb', line 62 def inspect # :nodoc: preview = body[0..32].inspect "#<content #{name} #{type} #{encoding} #{preview}>" end |
#save(filename = nil) ⇒ Object
Save the content to a file. If the filename is not provided then the content name is used instead. This is a convenience method used for method chaining.
flow.stream.contents.first.save
55 56 57 58 59 60 |
# File 'lib/mu/xtractr/content.rb', line 55 def save filename=nil open(filename || name, "w") do |ios| ios.write body end return self end |