Module: Plug::ArrayFeeder
- Includes:
- Base
- Defined in:
- lib/rbkb/plug/plug.rb
Overview
Uses an array of static messages as a datasource for opaque protocol messages. Useful as a generic blit-able loop
Instance Attribute Summary collapse
-
#close_at_end ⇒ Object
Returns the value of attribute close_at_end.
-
#feed ⇒ Object
Returns the value of attribute feed.
-
#go_first ⇒ Object
Returns the value of attribute go_first.
-
#pos ⇒ Object
Returns the value of attribute pos.
-
#squelch_exhausted ⇒ Object
Returns the value of attribute squelch_exhausted.
-
#step ⇒ Object
Returns the value of attribute step.
Attributes included from Base
#kind, #no_stop_on_unbind, #peers, #tls, #tls_opts, #transport
Instance Method Summary collapse
- #connection_completed ⇒ Object
- #feed_data(dst = plug_peer) ⇒ Object
- #go ⇒ Object
- #initialize(*args) ⇒ Object
- #say(dat, sender) ⇒ Object
Methods included from Base
#name, #plug_peer, #plug_receive, #post_init, #receive_data, #unbind
Instance Attribute Details
#close_at_end ⇒ Object
Returns the value of attribute close_at_end.
162 163 164 |
# File 'lib/rbkb/plug/plug.rb', line 162 def close_at_end @close_at_end end |
#feed ⇒ Object
Returns the value of attribute feed.
162 163 164 |
# File 'lib/rbkb/plug/plug.rb', line 162 def feed @feed end |
#go_first ⇒ Object
Returns the value of attribute go_first.
162 163 164 |
# File 'lib/rbkb/plug/plug.rb', line 162 def go_first @go_first end |
#pos ⇒ Object
Returns the value of attribute pos.
162 163 164 |
# File 'lib/rbkb/plug/plug.rb', line 162 def pos @pos end |
#squelch_exhausted ⇒ Object
Returns the value of attribute squelch_exhausted.
162 163 164 |
# File 'lib/rbkb/plug/plug.rb', line 162 def squelch_exhausted @squelch_exhausted end |
#step ⇒ Object
Returns the value of attribute step.
162 163 164 |
# File 'lib/rbkb/plug/plug.rb', line 162 def step @step end |
Instance Method Details
#connection_completed ⇒ Object
181 182 183 184 185 |
# File 'lib/rbkb/plug/plug.rb', line 181 def connection_completed peer=super() go if @go_first return peer end |
#feed_data(dst = plug_peer) ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/rbkb/plug/plug.rb', line 200 def feed_data(dst=plug_peer) unless dat=@feed[@pos] UI.log "** FEED EXHAUSTED" unless @squelch_exhausted return nil end dst.say dat.to_s, self if (@pos += 1) >= @feed.size and @close_at_end close_connection_after_writing end end |
#go ⇒ Object
174 175 176 177 178 179 |
# File 'lib/rbkb/plug/plug.rb', line 174 def go if @go_first feed_data @go_first = false end end |
#initialize(*args) ⇒ Object
165 166 167 168 169 170 171 172 |
# File 'lib/rbkb/plug/plug.rb', line 165 def initialize(*args) super(*args) @pos ||= 0 @feed ||= [] raise "feed must be enumerable" unless Enumerable === @feed end |