Class: Ldp::Resource::BinarySource

Inherits:
Ldp::Resource show all
Defined in:
lib/ldp/resource/binary_source.rb

Instance Attribute Summary collapse

Attributes inherited from Ldp::Resource

#client, #subject

Instance Method Summary collapse

Methods inherited from Ldp::Resource

#create, #current?, #delete, for, #get, #head, #new?, #reload, #retrieved_content?, #save, #subject_uri, #update, #update_cached_get

Constructor Details

#initialize(client, subject, content_or_response = nil, base_path = '') ⇒ BinarySource

Returns a new instance of BinarySource.



5
6
7
8
9
10
11
12
13
# File 'lib/ldp/resource/binary_source.rb', line 5

def initialize client, subject, content_or_response = nil, base_path = ''
  super

  case content_or_response
  when Faraday::Response
  else
    @content = content_or_response
  end
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



3
4
5
# File 'lib/ldp/resource/binary_source.rb', line 3

def content
  @content
end

Instance Method Details

#described_byObject



19
20
21
22
23
# File 'lib/ldp/resource/binary_source.rb', line 19

def described_by
  described_by = Array(head.links["describedby"]).first

  client.find_or_initialize described_by if described_by
end

#inspectObject

Override inspect so that ‘content` is never shown. It is typically too big to be helpful



26
27
28
29
30
# File 'lib/ldp/resource/binary_source.rb', line 26

def inspect
  string = "#<#{self.class.name}:#{self.object_id} "
  fields = [:subject].map{|field| "#{field}=\"#{self.send(field)}\""}
  string << fields.join(", ") << ">"
end