Class: Daberu::Talker
- Inherits:
-
Object
show all
- Defined in:
- lib/daberu/talker.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(obj = Object.new) ⇒ Talker
Returns a new instance of Talker.
9
10
11
12
|
# File 'lib/daberu/talker.rb', line 9
def initialize(obj = Object.new)
@obj = obj
@format = "Class: %s, Method: %s, Arguments: [%s], Block: %s"
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
14
15
16
17
|
# File 'lib/daberu/talker.rb', line 14
def method_missing(name, *args, &block)
p @format % [@obj.class, name, args.to_s.gsub(/^\[|\]$/, ""), block]
@obj.send(name, *args, &block)
end
|
Class Method Details
19
20
21
|
# File 'lib/daberu/talker.rb', line 19
def self.format_get(obj)
obj.__daberu_format_get__
end
|
23
24
25
|
# File 'lib/daberu/talker.rb', line 23
def self.format_set(obj, str)
obj.__daberu_format_set__(str)
end
|
.object_get(obj) ⇒ Object
27
28
29
|
# File 'lib/daberu/talker.rb', line 27
def self.object_get(obj)
obj.__daberu_object_get__
end
|
.object_set(obj, new) ⇒ Object
31
32
33
|
# File 'lib/daberu/talker.rb', line 31
def self.object_set(obj, new)
obj.__daberu_object_set__(new)
end
|
Instance Method Details
35
36
37
|
# File 'lib/daberu/talker.rb', line 35
def __daberu_format_get__
@format
end
|
39
40
41
|
# File 'lib/daberu/talker.rb', line 39
def __daberu_format_set__(str)
@format = str
end
|
#__daberu_object_get__ ⇒ Object
43
44
45
|
# File 'lib/daberu/talker.rb', line 43
def __daberu_object_get__
@obj
end
|
#__daberu_object_set__(obj) ⇒ Object
47
48
49
|
# File 'lib/daberu/talker.rb', line 47
def __daberu_object_set__(obj)
@obj = obj
end
|