Class: ArchiveBuilder::FileBuilder
- Inherits:
-
Object
- Object
- ArchiveBuilder::FileBuilder
- Includes:
- FileUtils
- Defined in:
- lib/archive_builder.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #create_dirs ⇒ Object
-
#initialize(filename) ⇒ FileBuilder
constructor
A new instance of FileBuilder.
- #with(content) ⇒ Object
Constructor Details
#initialize(filename) ⇒ FileBuilder
Returns a new instance of FileBuilder.
49 50 51 |
# File 'lib/archive_builder.rb', line 49 def initialize(filename) @filename = filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
48 49 50 |
# File 'lib/archive_builder.rb', line 48 def filename @filename end |
Instance Method Details
#create_dirs ⇒ Object
58 59 60 61 |
# File 'lib/archive_builder.rb', line 58 def create_dirs dirname = File.dirname(filename) mkdir_p dirname unless File.exists?(dirname) end |
#with(content) ⇒ Object
53 54 55 56 57 |
# File 'lib/archive_builder.rb', line 53 def with(content) create_dirs File.open(filename, "w+") { |f| f.puts content } return self end |