Sha256: f1a23c295053000d54126e4a4796e31fbcccc4133426ae6d6574d082e8d47961

Contents?: true

Size: 530 Bytes

Versions: 1

Compression:

Stored size: 530 Bytes

Contents

require 'stringio'

module Associo
  # Defines the file io for the attached file.
  class IO
    attr_accessor :name, :content, :type, :size

    def initialize(attrs = {})
      attrs.each { |key, value| send("#{key}=", value) }

      @type ||= 'plain/text'
    end

    def content=(value)
      @io   = StringIO.new(value || nil)
      @size = value ? value.size : 0
    end

    def read(*args)
      @io.read(*args)
    end

    def rewind
      @io.rewind if @io.respond_to?(:rewind)
    end

    alias path name
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
associo-0.1.0 lib/associo/io.rb