-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.rb
72 lines (63 loc) · 1.13 KB
/
class.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Pet = Class.new
dog = Pet.new
Kernel.puts(dog)
class Pet
def set_sound(my_sound)
@sound = my_sound
end
def speak
Kernel.puts("Listen to me #{@sound}!")
end
def sit(response)
if response == 'yes'
Kernel.puts ("good dog")
else
Kernel.puts ("bad dog")
end
end
def out(response)
Kernel.puts "#{response} I need to go out"
end
end
Smoothie = Class.new
class Smoothie
def set_blend(my_blend)
@blend = my_blend
end
def blend
Kernel.puts("Vrmrmrm, I'm blending at #{@blend} speeds!")
end
def crush
Kernel.puts ("crucrucrush")
end
end
Tomato = Class.new
grape = Tomato.new
Kernel.puts(grape)
class Tomato
def crush
Kernel.puts ("splat")
end
def ripe
Kernel.puts ("crunch")
end
end
class Marker
def set_color(my_color)
@color = my_color
end
def write
Kernel.puts("I am writing with a #{@color} marker!")
end
end
5.send(:*, 5)
"omg".send(:upcase)
['a', 'b', 'c'].send(:at, 1)
['a', 'b', 'c'].send(:insert, 2, 'o', 'h', 'n', 'o')
{}.send(:size)
{character: "Mario"}.send(:has_key?, :character)
6 - 32
{html: true, json:false}.keys
"MakerSquare" * 6
"MakerSquare".split('a')
['alpha', 'beta'].[](3)