Class: XmlConv::Util::DestinationDir
- Inherits:
-
Destination
- Object
- Destination
- XmlConv::Util::DestinationDir
- Defined in:
- lib/xmlconv/util/destination.rb
Constant Summary
Constants inherited from Destination
XmlConv::Util::Destination::STATUS_COMPARABLE
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Attributes inherited from Destination
Instance Method Summary collapse
- #deliver(delivery) ⇒ Object
- #do_deliver(delivery) ⇒ Object
-
#initialize(uri = URI.parse('/')) ⇒ DestinationDir
constructor
A new instance of DestinationDir.
- #update_status ⇒ Object
- #uri ⇒ Object
Methods inherited from Destination
book, #forget_credentials!, #sanitize, #status_comparable
Constructor Details
#initialize(uri = URI.parse('/')) ⇒ DestinationDir
Returns a new instance of DestinationDir.
62 63 64 65 |
# File 'lib/xmlconv/util/destination.rb', line 62 def initialize(uri = URI.parse('/')) @path = uri.path super() end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
61 62 63 |
# File 'lib/xmlconv/util/destination.rb', line 61 def filename @filename end |
Instance Method Details
#deliver(delivery) ⇒ Object
66 67 68 69 70 |
# File 'lib/xmlconv/util/destination.rb', line 66 def deliver(delivery) do_deliver(delivery) @status = :pending_pickup odba_store end |
#do_deliver(delivery) ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/xmlconv/util/destination.rb', line 71 def do_deliver(delivery) if(delivery.is_a?(Array)) delivery.each { |part| do_deliver(part) } else FileUtils.mkdir_p(@path) @filename = delivery.filename path = File.(sanitize(@filename), @path) File.open(path, 'w') { |fh| fh << delivery.to_s } end end |
#update_status ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/xmlconv/util/destination.rb', line 81 def update_status if(@status == :pending_pickup \ && !File.exist?(File.(sanitize(@filename), @path))) @status = :picked_up odba_store end end |
#uri ⇒ Object
88 89 90 |
# File 'lib/xmlconv/util/destination.rb', line 88 def uri URI.parse("file:#{File.(sanitize(@filename), @path)}") end |