Project

netstring

0.0
No commit activity in last 3 years
No release in over 3 years
A netstring parser and emitter
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
>= 0
~> 3.1
 Project Readme

Netstring: A netstring parser and emitter

Gem Version Build Status Coverage Status Code Climate

See the netstring specification for details.

Usage

require "netstring"

Dump:

netstring = Netstring.dump("xyz") # "3:xyz,"

Load:

string = Netstring.load("3:xyz,") # "xyz"

Get the netstring from which the string was loaded:

string.netstring # "3:xyz,"

Load concatenated netstrings:

netstring = "1:x,3:xyz,"
string1 = Netstring.load(netstring1) # "x"
offset = string1.netstring.size
netstring = netstring[offset..-1]
string2 = Netstring.load(netstring) # "xyz"

Load concatenated netstrings in a loop:

netstring = "1:x,3:xyz,"
strings = []
until netstring.empty?
  strings << Netstring.load(netstring)
  netstring = netstring[strings.last.netstring.size..-1]
end

Copyright (c) 2014 James McKinney, released under the MIT license