Class: YieldSource

Inherits:
Object show all
Defined in:
lib/yield_source.rb

Instance Method Summary collapse

Instance Method Details

#argsss(str) {|num_arr| ... } ⇒ Object

Yields:

  • (num_arr)


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

Yields:

  • (e_count)


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

Yields:

  • (output_hash)


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

Yields:

  • ("Get this out")

Returns:

  • (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

Yields:

  • (result)


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