-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.rb
More file actions
45 lines (43 loc) · 856 Bytes
/
class.rb
File metadata and controls
45 lines (43 loc) · 856 Bytes
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
class Marker
def set_color(my_color)
@color = my_color
end
def write
Kernel.puts("I am writing with a #{@color} marker!")
end
end
class Pet
def speak(noise)
@noise = noise
Kernel.puts("#{@noise}")
end
def pet_age(years)
@years = years
puts "Your pet is #{@years} years old.}"
end
def feed(food)
@food = food
puts "You fed your pet #{@food}."
end
end
class House
def price(dollar)
@dollar = dollar
puts "Your house costs #{dollar} dollars!"
end
def paint(color)
@color = color
puts "Your house is now #{color}. Very classy!"
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)