Class: Exegesis::Document::Attachment
- Inherits:
-
Object
- Object
- Exegesis::Document::Attachment
- Defined in:
- lib/exegesis/document/attachment.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #content_type ⇒ Object
- #file ⇒ Object
-
#initialize(name, thing, doc) ⇒ Attachment
constructor
A new instance of Attachment.
- #length ⇒ Object
- #stub? ⇒ Boolean
- #to_json ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(name, thing, doc) ⇒ Attachment
Returns a new instance of Attachment.
7 8 9 10 11 |
# File 'lib/exegesis/document/attachment.rb', line 7 def initialize(name, thing, doc) @document = doc @metadata = thing @name = name end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
5 6 7 |
# File 'lib/exegesis/document/attachment.rb', line 5 def document @document end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/exegesis/document/attachment.rb', line 5 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/exegesis/document/attachment.rb', line 5 def name @name end |
Instance Method Details
#content_type ⇒ Object
18 19 20 |
# File 'lib/exegesis/document/attachment.rb', line 18 def content_type @metadata['content_type'] end |
#file ⇒ Object
30 31 32 |
# File 'lib/exegesis/document/attachment.rb', line 30 def file RestClient.get("#{document.database.uri}/#{document.id}/#{name}") end |
#length ⇒ Object
22 23 24 |
# File 'lib/exegesis/document/attachment.rb', line 22 def length @metadata['length'] || -1 end |
#stub? ⇒ Boolean
26 27 28 |
# File 'lib/exegesis/document/attachment.rb', line 26 def stub? @metadata['stub'] || false end |
#to_json ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/exegesis/document/attachment.rb', line 34 def to_json if @metadata['data'] {'content_type' => @metadata['content_type'], 'data' => @metadata['data']}.to_json else @metadata.to_json end end |
#to_s ⇒ Object Also known as: inspect
13 14 15 |
# File 'lib/exegesis/document/attachment.rb', line 13 def to_s "#<Exegesis::Document::Attachment document=#{@document.uri} #{@metadata.inspect}>" end |