Class: IO

Inherits:
Object
  • Object
show all
Defined in:
lib/tagen/core/io.rb

Class Method Summary collapse

Class Method Details

.append(name, string, [offset], [open_args]) ⇒ Object

A convient method to append a file.

Examples:


File.append("/tmp/a", "hello world")

Parameters:

  • open_args (Hash)

See Also:



31
32
33
34
35
36
# File 'lib/tagen/core/io.rb', line 31

def append(name, string, *args)
  (offset,), o = args.extract_options
  o[:mode] = "a"

  write(name, string, offset, o)
end

.write(name, string, [offset], [open_args]) ⇒ Object Also known as: write

Extends IO#write with :mkdir option

Parameters:

  • open_args (Hash)


10
11
12
13
14
15
# File 'lib/tagen/core/io.rb', line 10

def write_with_tagen(name, string, *args)
  (offset,), o = args.extract_options
  mkdir_p(File.dirname(name)) if o[:mkdir]

  write_without_tagen(name, string, offset, o)
end