Class: ActionTexter::FileDelivery
- Inherits:
-
Object
- Object
- ActionTexter::FileDelivery
- Defined in:
- lib/action_texter/file_delivery.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
- #deliver(message) ⇒ Object
-
#initialize(config = {}) ⇒ FileDelivery
constructor
A new instance of FileDelivery.
Constructor Details
#initialize(config = {}) ⇒ FileDelivery
Returns a new instance of FileDelivery.
4 5 6 7 8 |
# File 'lib/action_texter/file_delivery.rb', line 4 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 |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
3 4 5 |
# File 'lib/action_texter/file_delivery.rb', line 3 def location @location end |
Instance Method Details
#deliver(message) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/action_texter/file_delivery.rb', line 10 def deliver() File.open(File.join(location, "#{.to}.txt"), "a") do |file| file.puts("FROM: #{.from}") file.puts(.body) file.puts("-"*40) end true end |