Class: Amberletters::BytesTrigger

Inherits:
Trigger
  • Object
show all
Defined in:
lib/amberletters.rb

Instance Attribute Summary collapse

Attributes inherited from Trigger

#exclusive, #interruption, #logger, #options, #time_to_live

Instance Method Summary collapse

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, options={}, &block)
  super(options, &block)
  @num_bytes = num_bytes
end

Instance Attribute Details

#num_bytesObject (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_sObject



141
142
143
# File 'lib/amberletters.rb', line 141

def to_s
  "#{num_bytes} bytes of output"
end