Sha256: ce0ececb28ce0faaf045ac1571cf21c7f781d9e9e619daffc3089d8070d1c3b8

Contents?: true

Size: 901 Bytes

Versions: 6

Compression:

Stored size: 901 Bytes

Contents

require "swa/record"

module Swa
  module S3

    class ObjectListEntry < Record

      def initialize(bucket_name, aws_record)
        @bucket_name = bucket_name
        super(aws_record)
      end

      attr_reader :bucket_name

      def to_s
        uri
      end

      def summary
        [
          pad(column1, 20),
          rpad(column2, 10),
          uri
        ].join("  ")
      end

    end

    class ObjectPrefix < ObjectListEntry

      delegate :prefix

      def column1
        "-"
      end

      def column2
        "-"
      end

      def uri
        "s3://#{bucket_name}/#{prefix}"
      end

    end

    class ObjectSummary < ObjectListEntry

      delegate :key, :size, :last_modified

      def column1
        last_modified.iso8601
      end

      def column2
        size
      end

      def uri
        "s3://#{bucket_name}/#{key}"
      end

    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
swa-0.8.3 lib/swa/s3/object_list_entry.rb
swa-0.8.2 lib/swa/s3/object_list_entry.rb
swa-0.8.1 lib/swa/s3/object_list_entry.rb
swa-0.8.0 lib/swa/s3/object_list_entry.rb
swa-0.7.7 lib/swa/s3/object_list_entry.rb
swa-0.7.6 lib/swa/s3/object_list_entry.rb