talking 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/lib/talking.rb +27 -0
- data/lib/talking/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a388f7fceabf7ef23972e5a0148f28639be83a8
|
4
|
+
data.tar.gz: e9991bd58529fbeae726fe9a4487d46d92a889dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ec1c276c4a0311162c83bfb8dd553b1f5e731d82510cbb00d7e923b5d4f8e6971d79856fd2f5ed70b8da6cf43162296f5532d0de2b2ccb8aec2087d02503f67
|
7
|
+
data.tar.gz: ebd8829e21cfc73e459bb9b45a31839c20733ea27e64c4621c855d1cd73efb076d55ec73f9e506db98701797a25e7cc63271f11957ddbb63dffb65a8fabb2c2b
|
data/README.md
CHANGED
@@ -55,6 +55,24 @@ def mouth
|
|
55
55
|
end
|
56
56
|
```
|
57
57
|
|
58
|
+
You can also add a proxy to your speaker objects:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
module Borat
|
62
|
+
class << self
|
63
|
+
include Talking::Talkative
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class Bruno
|
68
|
+
include Talking::TalkThrough
|
69
|
+
talk_through Borat
|
70
|
+
end
|
71
|
+
|
72
|
+
bruno = Bruno.new
|
73
|
+
bruno.say("Hello with Borat's voice!")
|
74
|
+
```
|
75
|
+
|
58
76
|
## Development
|
59
77
|
|
60
78
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/talking.rb
CHANGED
@@ -48,4 +48,31 @@ module Talking
|
|
48
48
|
)
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
# Public: A helper mixin that enables talking through other speakers.
|
53
|
+
module TalkThrough
|
54
|
+
def self.included(klass)
|
55
|
+
klass.extend(ClassMethods)
|
56
|
+
klass.extend(SingleForwardable)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Forwardable won't work here, we have to meta-define this stuff.
|
60
|
+
%w(say debug).each do |method|
|
61
|
+
define_method(method.to_sym) do |*args|
|
62
|
+
self.class.speaker.send(method, *args)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
module ClassMethods
|
67
|
+
# Public: Defines a speaker to talk through.
|
68
|
+
def talk_through(speaker)
|
69
|
+
@speaker = speaker
|
70
|
+
end
|
71
|
+
|
72
|
+
# Public: Returns defined speaker.
|
73
|
+
def speaker
|
74
|
+
@speaker
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
51
78
|
end
|
data/lib/talking/version.rb
CHANGED