Class: Micetrap::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/micetrap/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Server

Returns a new instance of Server.



8
9
10
11
12
13
14
15
# File 'lib/micetrap/server.rb', line 8

def initialize(options)
  raise StandardError.new("Service cannot be empty!") unless options[:service]
  @service = 
    eval("Micetrap::Services::#{options[:service].to_s.capitalize}").new
  @port = options[:port] # Optional
rescue NameError=>e
  raise Services::UnrecognizedServiceException.new("Service #{options[:service].to_s.capitalize} is not recognized")
end

Instance Attribute Details

#portObject (readonly)

Returns the value of attribute port.



6
7
8
# File 'lib/micetrap/server.rb', line 6

def port
  @port
end

#serviceObject (readonly)

Returns the value of attribute service.



5
6
7
# File 'lib/micetrap/server.rb', line 5

def service
  @service
end

Instance Method Details

#fire!Object



17
18
19
# File 'lib/micetrap/server.rb', line 17

def fire!
  @service.fire port
end