Sha256: 1b6b02efeac08ae4fc8304ceeed44a31c3f35bf747c664b049592287243da96f

Contents?: true

Size: 566 Bytes

Versions: 15

Compression:

Stored size: 566 Bytes

Contents

module Asynchronic
  module DataStore
    class Key < String
    
      SEPARATOR = '|'
      
      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

15 entries across 15 versions & 1 rubygems

Version Path
asynchronic-1.4.0 lib/asynchronic/data_store/key.rb
asynchronic-1.3.1 lib/asynchronic/data_store/key.rb
asynchronic-1.3.0 lib/asynchronic/data_store/key.rb
asynchronic-1.2.2 lib/asynchronic/data_store/key.rb
asynchronic-1.2.1 lib/asynchronic/data_store/key.rb
asynchronic-1.2.0 lib/asynchronic/data_store/key.rb
asynchronic-1.1.1 lib/asynchronic/data_store/key.rb
asynchronic-1.1.0 lib/asynchronic/data_store/key.rb
asynchronic-1.0.0 lib/asynchronic/data_store/key.rb
asynchronic-0.3.1 lib/asynchronic/data_store/key.rb
asynchronic-0.3.0 lib/asynchronic/data_store/key.rb
asynchronic-0.2.3 lib/asynchronic/data_store/key.rb
asynchronic-0.2.2 lib/asynchronic/data_store/key.rb
asynchronic-0.2.1 lib/asynchronic/data_store/key.rb
asynchronic-0.2.0 lib/asynchronic/data_store/key.rb