Class: HttpParser::Parser::Callback

Inherits:
FFI::Function
  • Object
show all
Defined in:
lib/http-parser/parser.rb

Class Method Summary collapse

Class Method Details

.new(&block) ⇒ Object

Creates a new Parser callback.



234
235
236
237
238
239
240
241
242
# File 'lib/http-parser/parser.rb', line 234

def self.new(&block)
    super(:int, [::HttpParser::Instance.ptr]) do |parser|
        begin
            catch(:return) { yield(parser); 0 }
        rescue
            -1
        end
    end
end