Class: Pansophy::Local::CreateFile
- Inherits:
-
Object
- Object
- Pansophy::Local::CreateFile
- Includes:
- Adamantium::Flat
- Defined in:
- lib/pansophy/local/create_file.rb
Instance Method Summary collapse
- #call(options = {}) ⇒ Object
-
#initialize(path, body) ⇒ CreateFile
constructor
A new instance of CreateFile.
Constructor Details
#initialize(path, body) ⇒ CreateFile
Returns a new instance of CreateFile.
6 7 8 9 |
# File 'lib/pansophy/local/create_file.rb', line 6 def initialize(path, body) @pathname = Pathname.new(path) @body = body end |
Instance Method Details
#call(options = {}) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/pansophy/local/create_file.rb', line 11 def call( = {}) prevent_overwrite! unless [:overwrite] @pathname.dirname.mkpath ::File.open(@pathname, 'wb') do |f| f.write @body end end |