Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/random_methods.rb
Instance Method Summary collapse
-
#alt_scan(item) ⇒ Object
test array for a substring, if string contains substring return the string.
- #print_all ⇒ Object
- #puts_all ⇒ Object
- #write_all(file) ⇒ Object
Instance Method Details
#alt_scan(item) ⇒ Object
test array for a substring, if string contains substring return the string
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/random_methods.rb', line 27 def alt_scan(item) # test array for a substring, if string contains substring return the string self.each do |var| begin if var[item] then return var end rescue puts "Variable not found." return nil end end end |
#print_all ⇒ Object
14 15 16 17 18 |
# File 'lib/random_methods.rb', line 14 def print_all self.each do |item| print "#{item} " end end |
#puts_all ⇒ Object
9 10 11 12 13 |
# File 'lib/random_methods.rb', line 9 def puts_all self.each do |item| puts item end end |
#write_all(file) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/random_methods.rb', line 19 def write_all(file) somefile = open(file, 'a') self.each do |item| somefile.puts(item) end somefile.close end |