Class: IO

Inherits:
Object
  • Object
show all
Defined in:
lib/xqsr3/doc_.rb,
lib/xqsr3/extensions/io/writelines.rb

Overview

Standard class, extended with methods:

  • IO#writelines

Class Method Summary collapse

Class Method Details

.writelines(path, contents, *args) ⇒ Object

Extends IO class with the ::Xqsr3::IO::write_lines method

def self.writelines(path, contents, lineSep = nil, columnSep = nil)



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/xqsr3/extensions/io/writelines.rb', line 61

def self.writelines(path, contents, *args)

	options = {}

	case args.size
	when 0

		;
	when 1

		arg3 = args[0]

		if arg3.respond_to?(:to_hash)

			options.merge! arg3.to_hash
		else

			options[:line_separator] = arg3
		end
	when 2

		arg3 = args[0]
		arg4 = args[1]

		options[:line_separator] = arg2
		options[:column_separator] = arg2
	else

		raise ArgumentError, "wrong number of arguments (given #{2 + args.size}, expected 2..4)"
	end

	::Xqsr3::IO.writelines path, contents, **options
end