Class: Fnord
- Inherits:
-
Object
- Object
- Fnord
- Defined in:
- lib/fnord.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#port ⇒ Object
Returns the value of attribute port.
-
#socket ⇒ Object
Returns the value of attribute socket.
Instance Method Summary collapse
- #event(type, options = {}) ⇒ Object
-
#initialize(attrs = {}) {|_self| ... } ⇒ Fnord
constructor
A new instance of Fnord.
- #time(type, options = {}, &block) ⇒ Object
Constructor Details
#initialize(attrs = {}) {|_self| ... } ⇒ Fnord
Returns a new instance of Fnord.
7 8 9 10 11 |
# File 'lib/fnord.rb', line 7 def initialize(attrs={}) self.socket = UDPSocket.new attrs.each {|k,v| send("#{k}=", v)} yield self if block_given? end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/fnord.rb', line 5 def host @host end |
#namespace ⇒ Object
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/fnord.rb', line 5 def namespace @namespace end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/fnord.rb', line 5 def port @port end |
#socket ⇒ Object
Returns the value of attribute socket.
5 6 7 |
# File 'lib/fnord.rb', line 5 def socket @socket end |
Instance Method Details
#event(type, options = {}) ⇒ Object
13 14 15 16 17 |
# File 'lib/fnord.rb', line 13 def event(type, ={}) = {_namespace: namespace}.merge() if namespace packet = { _type: type }.merge() send_data packet.to_json end |
#time(type, options = {}, &block) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/fnord.rb', line 19 def time(type, ={}, &block) start = Time.now result = yield event type, .merge({time: ((Time.now-start)*1000).round}) result end |