Method: AppInfo::Helper::IOBlock#left_bytes_check
- Defined in:
- lib/app_info/helper/signatures.rb
#left_bytes_check(io, max_bytes, exception, message = nil, &block) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/app_info/helper/signatures.rb', line 51 def left_bytes_check(io, max_bytes, exception, = nil, &block) return if max_bytes.nil? left_bytes = io.size - io.pos return left_bytes if left_bytes.zero? ||= if block_given? block.call(left_bytes) else "IO too short: #{offset} < #{max_bytes}" end raise exception, if left_bytes < max_bytes left_bytes end |