Sha256: e52b8d721d74edadace1052e92b248fa3528c17780afd741014f482e3d793d7c

Contents?: true

Size: 616 Bytes

Versions: 13

Compression:

Stored size: 616 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

13 entries across 13 versions & 1 rubygems

Version Path
asynchronic-3.0.3 lib/asynchronic/data_store/key.rb
asynchronic-3.0.2 lib/asynchronic/data_store/key.rb
asynchronic-3.0.1 lib/asynchronic/data_store/key.rb
asynchronic-3.0.0 lib/asynchronic/data_store/key.rb
asynchronic-2.0.1 lib/asynchronic/data_store/key.rb
asynchronic-2.0.0 lib/asynchronic/data_store/key.rb
asynchronic-1.6.3 lib/asynchronic/data_store/key.rb
asynchronic-1.6.2 lib/asynchronic/data_store/key.rb
asynchronic-1.6.1 lib/asynchronic/data_store/key.rb
asynchronic-1.6.0 lib/asynchronic/data_store/key.rb
asynchronic-1.5.2 lib/asynchronic/data_store/key.rb
asynchronic-1.5.1 lib/asynchronic/data_store/key.rb
asynchronic-1.5.0 lib/asynchronic/data_store/key.rb