Sha256: ad837b48a4e798c328c130559d5f426f0785890c3a0080d4355bda69aa200c39

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Roro
  module Configurators
    class AdventureChooser
      include Utilities

      attr_reader :itinerary, :stack, :manifest

      def initialize
        @asker     = AdventurePicker.new
        @itinerary = []
        @stack     = Roro::CLI.catalog_root
      end

      def build_itinerary(stack=nil)
        @manifest ||= []
        stack ||= @stack
        case stack_type(stack)
        when :storyfile
          @manifest << stack
        when :story
          @manifest += stack_stories(stack)
        when :stack
          @manifest += stack_stories(stack)
          children(stack).each { |c| build_itinerary(c) }
        when :inflection
          child = choose_adventure(stack)
          @itinerary << child if stack_type(child).eql?(:story)
          build_itinerary(child)
        end
        @manifest.uniq!
        @itinerary.uniq!
      end

      def stack_is_alias?(catalog)
        stack_is_storyfile?(catalog) &&
          !read_yaml(catalog)[:aliased_to].nil?
      end

      def choose_adventure(inflection)
        @asker.choose_adventure(inflection)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
roro-0.3.28 lib/roro/configurators/adventure_chooser.rb
roro-0.3.27 lib/roro/configurators/adventure_chooser.rb
roro-0.3.25 lib/roro/configurators/adventure_chooser.rb
roro-0.3.24 lib/roro/configurators/adventure_chooser.rb
roro-0.3.23 lib/roro/configurators/adventure_chooser.rb