-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobj_23.rb
More file actions
executable file
·46 lines (37 loc) · 795 Bytes
/
robj_23.rb
File metadata and controls
executable file
·46 lines (37 loc) · 795 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
46
#!/usr/bin/env ruby
require "./ruler"
#-----------------------------------------------------------------------------
R("")
class Thing
attr_accessor :name
def initialize(options = {})
@name = options[:name] || "unknown"
end
def to_s
"to_s:#{@name}"
end
def to_a
["to_a:#{@name}"]
end
def to_ary
["to_ary:#{@name}"]
end
def method_missing(method_name)
puts "> Missing method: #{method_name}"
super
end
end
t = Thing.new({ name: "wojtek" } )
puts t
print t, "\n"
#t.dupa
#-----------------------------------------------------------------------------
R("How include? works")
a = [ 1, 2, 3]
x = 2
puts "Callling include?(#{x}) on a = ", a
puts "Is equal to: ", a.include?(x)
puts "---"
a = [ 'wojtek', 'koszek', 'adam']
puts a.include?(a[0])
puts a.include?(:wojtek)