Sha256: 1409b05f148cb90e3193d8fc6eb699e01126434a340c7070b0e78aed3587f2ce

Contents?: true

Size: 455 Bytes

Versions: 3

Compression:

Stored size: 455 Bytes

Contents

# frozen_string_literal: true

require_relative '../structs/trunk'

module Umwelt::Tree
  class Trunk < Struct::Trunk
    def nodes
      index
        .values
        .map { |fragment| builder.call(fragment) }
    end

    def node(id)
      builder.call(index[id])
    end

    def childs(id)
      childs_ids[id].map { |child_id| node(child_id) }
    end

    private

    def builder
      @builder ||= Umwelt::Node::Build.new(self)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
umwelt-0.2 lib/umwelt/tree/trunk.rb
umwelt-0.1.1 lib/umwelt/tree/trunk.rb
umwelt-0.1.0 lib/umwelt/tree/trunk.rb