Sha256: ec95bba7687dca7fe25c2443e29bac7086a7eeb09c940686c4f82e9a4b9b29ff

Contents?: true

Size: 560 Bytes

Versions: 1

Compression:

Stored size: 560 Bytes

Contents

module ActionTexter
  class FileDelivery
    attr_reader :location
    def initialize(config = {})
      @location = config[:location]
      raise ArgumentError, "you must specify config.action_texter.file_settings to contain a :location" unless @location
      Dir.mkdir(@location) unless Dir.exists?(@location)
    end

    def deliver(message)
      File.open(File.join(location, "#{message.to}.txt"), "a") do |file|
        file.puts("FROM: #{message.from}")
        file.puts(message.body)
        file.puts("-"*40)
      end
      true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
actiontexter-0.1.0 lib/action_texter/file_delivery.rb