Class: Amberletters::BytesTrigger
- Defined in:
- lib/amberletters.rb
Instance Attribute Summary collapse
-
#num_bytes ⇒ Object
readonly
Returns the value of attribute num_bytes.
Attributes inherited from Trigger
#exclusive, #interruption, #logger, #options, #time_to_live
Instance Method Summary collapse
- #call(process) ⇒ Object
-
#initialize(num_bytes, options = {}, &block) ⇒ BytesTrigger
constructor
A new instance of BytesTrigger.
- #to_s ⇒ Object
Constructor Details
#initialize(num_bytes, options = {}, &block) ⇒ BytesTrigger
Returns a new instance of BytesTrigger.
136 137 138 139 |
# File 'lib/amberletters.rb', line 136 def initialize(num_bytes, ={}, &block) super(, &block) @num_bytes = num_bytes end |
Instance Attribute Details
#num_bytes ⇒ Object (readonly)
Returns the value of attribute num_bytes.
134 135 136 |
# File 'lib/amberletters.rb', line 134 def num_bytes @num_bytes end |
Instance Method Details
#call(process) ⇒ Object
145 146 147 148 149 150 151 152 153 |
# File 'lib/amberletters.rb', line 145 def call(process) @logger.debug "checking if #{num_bytes} byes have been received" if process.rest_size >= num_bytes @block.call(self, process) true else false end end |
#to_s ⇒ Object
141 142 143 |
# File 'lib/amberletters.rb', line 141 def to_s "#{num_bytes} bytes of output" end |