Sha256: 3a99be323d9ab060b130cfc321f570a3abe48eb2d463b321a60e68276b5d6cf3

Contents?: true

Size: 728 Bytes

Versions: 1

Compression:

Stored size: 728 Bytes

Contents

require 'pgit'

module PGit
  module Bilateral
    class HandleChooseStory < ResponseHandler
      def initialize(options)
        @response = options.fetch(:response)
        @stories = options.fetch(:stories)
        @response_handlers = [PGit::Bilateral::HandleBack]
        name_parser = PGit::StoryBranch::NameParser.new(chosen_story)
        story_branch = PGit::StoryBranch.new(name_parser)

        story_branch.start
      end

      private

      def chosen_story
        @stories[@response.to_i]
      end

      def options(new_response)
        { response: new_response, stories: @stories, parent_question: @parent_question }
      end

      def response_can_be_handled?
        false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pgit-1.0.0 lib/pgit/bilateral/handle_choose_story.rb