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.
- #bool_scan(item) ⇒ Object
- #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
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/random_methods.rb', line 47 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 return nil end end end |
#bool_scan(item) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/random_methods.rb', line 59 def bool_scan(item) self.each do |var| begin if var == item then return true end rescue return false end end end |
#print_all ⇒ Object
34 35 36 37 38 |
# File 'lib/random_methods.rb', line 34 def print_all self.each do |item| print "#{item} " end end |
#puts_all ⇒ Object
29 30 31 32 33 |
# File 'lib/random_methods.rb', line 29 def puts_all self.each do |item| puts item end end |
#write_all(file) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/random_methods.rb', line 39 def write_all(file) somefile = open(file, 'a') self.each do |item| somefile.puts(item) end somefile.close end |