Module: RoSupport::FileActions
- Included in:
- RoSupport
- Defined in:
- lib/ro_support/file_actions.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Attentions: module_name must be like file_name eg: module Array, array.rb is right eg: moduel ArrayDSL, array.rb is wrong The File tree is like this: a -b.rb -c.rb a.rb.
Instance Method Summary collapse
-
#parent(path) ⇒ Object
def file(path) parent(path) File.new(path, ‘w+’) end.
- #write(path, content) ⇒ Object
Class Method Details
.included(base) ⇒ Object
Attentions: module_name must be like file_name eg: module Array, array.rb is right eg: moduel ArrayDSL, array.rb is wrong The File tree is like this: a -b.rb -c.rb a.rb
42 43 44 |
# File 'lib/ro_support/file_actions.rb', line 42 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#parent(path) ⇒ Object
def file(path)
parent(path)
File.new(path, 'w+')
end
27 28 29 30 31 |
# File 'lib/ro_support/file_actions.rb', line 27 def parent(path) file = File.basename path dir = path.gsub file, '' FileUtils.mkdir_p(dir) end |
#write(path, content) ⇒ Object
17 18 19 20 |
# File 'lib/ro_support/file_actions.rb', line 17 def write(path, content) parent(path) File.write path end |