Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Proxy that parses TNetstring lazily
Ruby
tag: v0.1.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.rvmrc
Gemfile
LICENSE
README.md
Rakefile
lazy_tnetstring.gemspec

README.md

Lazy TNetstring

Data Accessor to lazy parse and update tnetstrings.

Usage

Say you have a tnetstring (see http://tnetstrings.org/) assigned to data

data = "92:4:key1,6:value1,5:inner,48:4:key1,13:inner value 1,4:key2,13:inner value 2,}4:key2,6:value2,}"

that resembles the following Ruby Hash

{
  'key1' => 'value1',
  'inner' => {
    'key1' => 'inner value 1',
    'key2' => 'inner value 2'
  },
  'key2' => 'value2'
}

you can interact with it like this

>> require 'lazy_tnetstring'
=> true

>> da = LazyTNetstring::DataAccess.new(data)
=> #<LazyTNetstring::DataAccess ...>

# hash-like access
>> da['inner']['key2']
=> "inner value 2"

# updating values
>> da['inner']['key2'] = 'new value'
=> "new value"

# your data will be updated in place!
>> data
=> "87:4:key1,6:value1,5:inner,43:4:key1,13:inner value 1,4:key2,9:new value,}4:key2,6:value2,}"

# accessing unknown keys yields nil
>> da['nonexisting']
=> nil

Installation

gem install lazy_tnetstring

Copyright

Copyright (c) 2011 wooga GmbH http://www.wooga.com. See LICENSE (MIT) for details.

Something went wrong with that request. Please try again.