Sha256: 7257438bacdbdd8baf6ae513cf8c06f5daae8be2ebdefdd12ed77f41e0dff90c

Contents?: true

Size: 688 Bytes

Versions: 4

Compression:

Stored size: 688 Bytes

Contents

module Buoys
  class Renderer
    def initialize(context, key, *args)
      @context = context
      @key = key
      @args = args

      Buoys::Loader.load_buoys_files
    end

    def render
      return [] unless @key

      buoy = Buoys::Buoy.new(@context, @key, *@args)
      build_links(buoy)
    end

    private

    def build_links(buoy)
      links = buoy.links.dup

      links.unshift(*collect_previous_links(buoy))
      links.last.mark_as_current!

      links
    end

    def collect_previous_links(buoy)
      links = []

      buoy = buoy.previous
      while buoy
        links.unshift(*buoy.links)
        buoy = buoy.previous
      end

      links
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
buoys-0.6.0 lib/buoys/renderer.rb
buoys-0.5.0 lib/buoys/renderer.rb
buoys-0.4.0 lib/buoys/renderer.rb
buoys-0.3.0 lib/buoys/renderer.rb