Sha256: 6d221bfc2c3fd6245525fabb1693e3996bcb1f48be6c457261a6399016eefc2c

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 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.stacks
      end

      def build_itinerary(stack=nil)
        @manifest ||= []
        stack ||= @stack
        case stack_type(stack)
        when :storyfile
          @manifest << stack
        when :story
          @itinerary << stack.split("#{Roro::CLI.stacks}/").last
          @manifest += stack_stories(stack)
        when :stack
          @manifest += stack_stories(stack)
          children(stack).each { |c| build_itinerary(c) }
        when :inflection_stub
          children(stack).each { |c| build_itinerary(c) }
        when :inflection
          child = choose_adventure(stack)
          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

1 entries across 1 versions & 1 rubygems

Version Path
roro-0.3.33 lib/roro/configurators/adventure_chooser.rb