Sha256: af5fa9961e097a84c94306655a955973b7bd4fb3b67e26e6a9eb406580511f5c

Contents?: true

Size: 776 Bytes

Versions: 7

Compression:

Stored size: 776 Bytes

Contents

module Ldp
  class Resource::BinarySource < Ldp::Resource
    attr_accessor :content

    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

    def content
      @content ||= get.body
    end

    def described_by
      client.find_or_initialize Array(Ldp::Response.links(self)["describedby"]).first
    end

    # Override inspect so that `content` is never shown. It is typically too big to be helpful
    def inspect
      string = "#<#{self.class.name}:#{self.object_id} "
      fields = [:subject].map{|field| "#{field}=\"#{self.send(field)}\""}
      string << fields.join(", ") << ">"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ldp-0.4.1 lib/ldp/resource/binary_source.rb
ldp-0.4.0 lib/ldp/resource/binary_source.rb
ldp-0.3.1 lib/ldp/resource/binary_source.rb
ldp-0.3.0 lib/ldp/resource/binary_source.rb
ldp-0.2.3 lib/ldp/resource/binary_source.rb
ldp-0.2.2 lib/ldp/resource/binary_source.rb
ldp-0.2.1 lib/ldp/resource/binary_source.rb