Class: Libevent::Builder
- Inherits:
-
Object
- Object
- Libevent::Builder
- Defined in:
- lib/libevent/builder.rb
Instance Attribute Summary (collapse)
-
- (Object) base
readonly
Returns the value of attribute base.
Instance Method Summary (collapse)
-
- (Object) dispatch
Start event base loop.
-
- (Builder) initialize(options = {}, &block)
constructor
A new instance of Builder.
-
- (Http) server(host, port) {|http| ... }
Create new Http instance, bind socket and options yield http object.
-
- (Object) signal(name, &block)
Trap signal using event base.
Constructor Details
- (Builder) initialize(options = {}, &block)
A new instance of Builder
3 4 5 6 |
# File 'lib/libevent/builder.rb', line 3 def initialize( = {}, &block) @base = Base.new instance_eval(&block) if block_given? end |
Instance Attribute Details
- (Object) base (readonly)
Returns the value of attribute base
8 9 10 |
# File 'lib/libevent/builder.rb', line 8 def base @base end |
Instance Method Details
- (Object) dispatch
Start event base loop
28 29 30 |
# File 'lib/libevent/builder.rb', line 28 def dispatch base.dispatch end |
- (Http) server(host, port) {|http| ... }
Create new Http instance, bind socket and options yield http object
14 15 16 17 18 19 |
# File 'lib/libevent/builder.rb', line 14 def server(host, port, &block) http = Http.new(@base) http.bind_socket(host, port) or raise RuntimeError, "can't bind socket #{host}:#{port}" yield(http) if block_given? http end |
- (Object) signal(name, &block)
Trap signal using event base
23 24 25 |
# File 'lib/libevent/builder.rb', line 23 def signal(name, &block) base.trap_signal(name, &block) end |