class YieldSource
Public Instance Methods
argsss(str) { |*num_arr| ... }
click to toggle source
# 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| ... }
click to toggle source
# 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) { |true| ... }
click to toggle source
# 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| ... }
click to toggle source
# 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() { |"\nWell done!\n\n".yellow + "This one just reinforces the last one.\nMove on to the next problem.\n".red| ... }
click to toggle source
# 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) { |"\t#{num}".red| ... }
click to toggle source
# 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) { |result| ... }
click to toggle source
# 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