Class: RVM::Functions::Align

Inherits:
Function show all
Defined in:
lib/rvm/functions/list/align.rb

Overview

:nodoc:

Class Method Summary collapse

Methods inherited from Function

call, data_type, execargs, method_missing

Methods included from Plugin

#helper, #included, #plugin_host, #plugin_id, #register_for

Class Method Details

.execute(params, env) ⇒ Object

TODO: Fix this



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rvm/functions/list/align.rb', line 29

def Align.execute params, env
	if params.length >=2
		alignments = params.shift
		alignments.map! { |i| i.to_i }
		data = []
		alignments.size.times do
			data << params.shift || []
		end

		filler = params.shift || " "
		filler = filler.to_s
		colsep = params.shift || " "
		colsep = colsep.to_s
		rowsep = params.shift || "\n"
		rowsep = rowsep.to_s
		running = true
		str = ""
		while running
			i = 0;
			running = false
			alignments.each do |arg|
				running = (item = data[i].shift) || running
				if arg > 0
					str << ljust(item || "",arg,filler)
				else
					str << rjust(item || "",arg*-1,filler)
				end
				str << colsep
				i =+ 1
			end
			str << rowsep
		end
		RVM::Classes[:string].new(str.gsub(/[\n\s]+$/,''))
	else
		RVM::Classes[:error].new(1,"#-1 FUNCTION (#{self.class.to_s}) EXPECTS 2 OR MORE ARGUMENTS BUT GOT #{params.length}")
	end
end

.signatureObject



67
68
69
# File 'lib/rvm/functions/list/align.rb', line 67

def Align.signature
	[:list]
end