Class: YieldSource
Instance Method Summary collapse
- #argsss(str) {|num_arr| ... } ⇒ Object
- #how_many(str) {|e_count| ... } ⇒ Object
- #now_what(arr) ⇒ Object
- #str_to_what(sentence) {|output_hash| ... } ⇒ Object
- #what_is_it? {|"Get this out"| ... } ⇒ Boolean
- #what_is_it_this_time(str) ⇒ Object
- #yielder(num1, num2) {|result| ... } ⇒ Object
Instance Method Details
#argsss(str) {|num_arr| ... } ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/yield_source.rb', line 46 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) {|e_count| ... } ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/yield_source.rb', line 24 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(e_count) end |
#now_what(arr) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/yield_source.rb', line 55 def now_what(arr) if arr.length % 3 == 0 yield(true) else yield(false) end end |
#str_to_what(sentence) {|output_hash| ... } ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/yield_source.rb', line 63 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? {|"Get this out"| ... } ⇒ Boolean
13 14 15 16 |
# File 'lib/yield_source.rb', line 13 def what_is_it?() yield("Get this out") puts("Here it is..!") end |
#what_is_it_this_time(str) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/yield_source.rb', line 35 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(num) end end |
#yielder(num1, num2) {|result| ... } ⇒ Object
18 19 20 21 22 |
# File 'lib/yield_source.rb', line 18 def yielder(num1, num2) result = num1 ** num2 yield(result) puts("After the yield..") end |