Class: Fnord::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fnord/client.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port = 1337, options = {}) ⇒ Client

Returns a new instance of Client.



15
16
17
# File 'lib/fnord/client.rb', line 15

def initialize(host, port = 1337, options = {})
  @host, @port, @options = host, port, options
end

Class Attribute Details

.loggerObject

Set to any standard logger instance (including stdlib’s Logger) to enable stat logging using logger.debug



10
11
12
# File 'lib/fnord/client.rb', line 10

def logger
  @logger
end

.namespaceObject

Set to any standard logger instance (including stdlib’s Logger) to enable stat logging using logger.debug



10
11
12
# File 'lib/fnord/client.rb', line 10

def namespace
  @namespace
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



13
14
15
# File 'lib/fnord/client.rb', line 13

def connection
  @connection
end

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/fnord/client.rb', line 5

def host
  @host
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/fnord/client.rb', line 5

def options
  @options
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/fnord/client.rb', line 5

def port
  @port
end

Instance Method Details

#event(*args) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/fnord/client.rb', line 19

def event(*args)
  message = extract_options!(args)
  event_name = args.shift
  message[:_type] = event_name if event_name
  message[:_namespace] = self.class.namespace unless message[:_namespace]
  message = stringify_values(message)
  send_to_connection(to_json(message))
end