Class: YieldSource
Instance Method Summary collapse
- #argsss(str) {|num_arr| ... } ⇒ Object
- #how_many(str) {|"\n\t#{e_count}\n".green| ... } ⇒ Object
- #now_what(arr) ⇒ Object
- #str_to_what(sentence) {|output_hash| ... } ⇒ Object
- #what_is_it ⇒ Object
- #what_is_it_this_time(str) ⇒ Object
- #yielder(num1, num2) ⇒ Object
Instance Method Details
#argsss(str) {|num_arr| ... } ⇒ Object
110 111 112 113 114 115 116 117 |
# File 'lib/yield_source.rb', line 110 def argsss(str) space_split = str.split(' ') num_arr = [] space_split.each do |sub_str| num_arr << sub_str.length end yield(*num_arr) end |
#how_many(str) {|"\n\t#{e_count}\n".green| ... } ⇒ Object
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/yield_source.rb', line 88 def how_many(str) e_count = 0 str_arr = str.downcase.split('') str_arr.each do |letter| if letter == 'e' e_count += 1 end end yield("\n\t#{e_count}\n".green) end |
#now_what(arr) ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/yield_source.rb', line 119 def now_what(arr) if arr.length % 3 == 0 yield(true) else yield(false) end end |
#str_to_what(sentence) {|output_hash| ... } ⇒ Object
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/yield_source.rb', line 127 def str_to_what(sentence) str_parts = sentence.split(' ') counter = 0 output_hash = {} while counter < str_parts.length output_hash[str_parts[counter].downcase.to_sym] = str_parts[counter+1] counter += 2 end yield(output_hash) end |
#what_is_it ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/yield_source.rb', line 62 def what_is_it() # system 'clear' if File.file?("./zmem.txt") File.delete("./zmem.txt") end if !block_given? system 'clear' puts("\nNot again!!".yellow) puts("Gimme a BLOCK!\n".red) else yield("\nWell done!\n\n".yellow + "This one just reinforces the last one.\nMove on to the next problem.\n".red) end end |
#what_is_it_this_time(str) ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/yield_source.rb', line 99 def what_is_it_this_time(str) s_split = str.split('s') num_arr = [] s_split.each do |sub_str| num_arr << sub_str.length end num_arr.each do |num| yield("\t#{num}".red) end end |
#yielder(num1, num2) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/yield_source.rb', line 76 def yielder(num1, num2) if !block_given? system 'clear' puts("\nGrrrrrrrrrrrrrrrr!\n".magenta) else puts("\nBefore the yield..\n".light_blue) result = num1 ** num2 yield(result) puts("\n..after the yield.\n".light_blue) end end |