Class: Statsdeify::Writer
- Inherits:
-
Object
- Object
- Statsdeify::Writer
- Defined in:
- lib/statsdeify/writer.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url) ⇒ Writer
constructor
A new instance of Writer.
- #puts(measurement) ⇒ Object
- #socket ⇒ Object
Constructor Details
#initialize(url) ⇒ Writer
Returns a new instance of Writer.
5 6 7 |
# File 'lib/statsdeify/writer.rb', line 5 def initialize(url) self.url = url end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/statsdeify/writer.rb', line 3 def url @url end |
Instance Method Details
#puts(measurement) ⇒ Object
18 19 20 |
# File 'lib/statsdeify/writer.rb', line 18 def puts(measurement) socket.send(measurement.to_s, 0) end |
#socket ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/statsdeify/writer.rb', line 9 def socket unless @socket uri = URI.parse(url) @socket = UDPSocket.new @socket.connect(uri.host, uri.port) end @socket end |