Sha256: a1d029c1fe686326e314f3b0da3bf31b53e8c6608537d91a97b06bf02cae158b

Contents?: true

Size: 732 Bytes

Versions: 4

Compression:

Stored size: 732 Bytes

Contents

module Rambling
  module Trie
    # Provides pretty printing behavior for the trie data structure.
    module Inspectable
      # @return [String] a string representation of the current node.
      def inspect
        "#<#{class_name} #{attributes}>"
      end

      private

      def class_name
        self.class.name
      end

      def attributes
        [
          letter_inspect,
          terminal_inspect,
          children_inspect,
        ].join ', '
      end

      def letter_inspect
        "letter: #{letter.inspect}"
      end

      def terminal_inspect
        "terminal: #{terminal.inspect}"
      end

      def children_inspect
        "children: #{children_tree.keys.inspect}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rambling-trie-1.0.3 lib/rambling/trie/inspectable.rb
rambling-trie-1.0.2 lib/rambling/trie/inspectable.rb
rambling-trie-1.0.1 lib/rambling/trie/inspectable.rb
rambling-trie-1.0.0 lib/rambling/trie/inspectable.rb