-
Notifications
You must be signed in to change notification settings - Fork 0
/
class.rb
108 lines (63 loc) · 1.29 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
class Pet
def speak
#Kernel.puts("Woof Woof")
Kernel.puts("What noise does Sadie make?")
noise = gets.chomp
Kernel.puts("Sadie likes to #{noise}")
end
def go_outside(bark)
if bark >= 2
"You must need to go outside!"
else
"Sadie is just dreaming."
end
end
def walkies(lead)
"To go for a walk we need #{lead} lead and a collar."
end
def bark(noise)
noise = noise
"Sadie likes to #{@noise}"
end
end
dog = Pet.new
Kernel.puts(dog)
dog.go_outside(1)
dog.walkies(1)
dog.bark("yip")
5.send(:*, 5)
25
"omg".send(:upcase)
"OMG"
['a', 'b' ,'c'].send(:at, 1)
"b"
['a', 'b', 'c'].send(:insert, 2, 'o', 'h', 'n', 'o')
["a", "b", "o", "h", "n", "o", "c"]
{}.send(:size)
0
{charcater: "Mario"}.send(:has_key?, :character)
false
6-32
-26
{html: true, json: false}.keys
[:html, :json]
"MakerSquare"*6
"MakerSquareMakerSquareMakerSquareMakerSquareMakerSquareMakerSquare"
"MakerSquare".split('a')
["M", "kerSqu", "re"]
['alpha', 'beta'].at(3)
nil
#class Marker
# def set_color(my_color)
# @color = my_color
# end
# def write
# Kernel.puts("I am writing with a #{@color} marker!")
# end
# end
# red_marker = Marker.new
# green_marker = Marker.new
# red_marker.set_color("red")
# green_marker.set_color("green")
# red_marker.write
# green_marker.write