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
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/random_methods.rb', line 34 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
21 22 23 24 25 |
# File 'lib/random_methods.rb', line 21 def print_all self.each do |item| print "#{item} " end end |
#puts_all ⇒ Object
16 17 18 19 20 |
# File 'lib/random_methods.rb', line 16 def puts_all self.each do |item| puts item end end |
#write_all(file) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/random_methods.rb', line 26 def write_all(file) somefile = open(file, 'a') self.each do |item| somefile.puts(item) end somefile.close end |