Sha256: f44db0b078f21d140c1907a8bf8a8ec1e27db068cacfe972721cc0fd75eed9a9

Contents?: true

Size: 607 Bytes

Versions: 4

Compression:

Stored size: 607 Bytes

Contents

module Asynchronic
  module DataStore
    class Key < String

      SEPARATOR = '|'

      def self.[](key)
        new key
      end

      def initialize(key)
        super key.to_s
      end

      def [](key)
        self.class.new [self, key].join(SEPARATOR)
      end

      def sections
        split SEPARATOR
      end

      def nested?
        sections.count > 1
      end

      def remove_first(count=1)
        self.class.new sections[count..-1].join(SEPARATOR)
      end

      def remove_last(count=1)
        self.class.new sections[0..-count-1].join(SEPARATOR)
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
asynchronic-4.0.3 lib/asynchronic/data_store/key.rb
asynchronic-4.0.2 lib/asynchronic/data_store/key.rb
asynchronic-4.0.1 lib/asynchronic/data_store/key.rb
asynchronic-4.0.0 lib/asynchronic/data_store/key.rb