Class: Array

Inherits:
Object show all
Defined in:
lib/basic/basic.rb

Direct Known Subclasses

Stack, Token

Instance Method Summary collapse

Instance Method Details

#assert_all_types(clas, msg = nil) ⇒ Object


102
103
104
105
106
# File 'lib/basic/basic.rb', line 102

def assert_all_types clas, msg = nil
	each { |x|
		x.assert_type clas, msg
	}
end

#contains?(*elements) ⇒ Boolean

Returns:

  • (Boolean)

108
109
110
111
112
113
# File 'lib/basic/basic.rb', line 108

def contains? *elements
	elements.each { |element|
		if !include?( element ) then return false end
	}
	true
end

#findObject


81
82
83
84
85
86
87
88
89
90
# File 'lib/basic/basic.rb', line 81

def find
	ctr = 0
	each { |e|
		if yield( e )
			return ctr
		end
	}

	nil
end

#prep_insert(table) ⇒ Object


92
93
94
95
96
97
98
99
100
# File 'lib/basic/basic.rb', line 92

def prep_insert table
	set = []

	each { |line|
		set = "( #{line.join ','} )"
	}

	set = "insert into #{table} values ( #{set.join ','} ),"
end

#to_sObject

buggy Ruby is supposed to do this already…


116
117
118
119
120
# File 'lib/basic/basic.rb', line 116

def to_s
	collect { |x|
		x.to_s
	}.join
end