Sha256: cc815de89540cea90c1c3743bbb4ce08695537e1e0564f4a5b1813213df19435

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

module Gamefic
  module Props
    # A collection of data related to a scene. Scenes define which Props class
    # they use. Props can be accessed in a scene's on_start and on_finish
    # callbacks.
    #
    # Props::Default includes the most common attributes that a scene requires.
    # Scenes are able but not required to subclass it. Some scenes, like
    # MultipleChoice, use specialized Props subclasses, but in many cases,
    # Props::Default is sufficient.
    #
    class Default
      # @return [String]
      attr_writer :prompt

      # @return [String]
      attr_accessor :input

      # A freeform dictionary of objects related to the scene. Plots can pass
      # opts to be included in the context when they cue scenes.
      #
      # @return [Hash]
      attr_reader :context
      alias data context

      # @return [Hash]
      attr_reader :scene

      # @param scene [Scene]
      # @param context [Hash]
      def initialize scene, **context
        @scene = { name: scene.name, type: scene.type }
        @context = context
      end

      def prompt
        @prompt ||= '>'
      end

      def output
        @output ||= Props::Output.new
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gamefic-3.6.0 lib/gamefic/props/default.rb
gamefic-3.5.0 lib/gamefic/props/default.rb
gamefic-3.4.0 lib/gamefic/props/default.rb
gamefic-3.3.0 lib/gamefic/props/default.rb
gamefic-3.2.1 lib/gamefic/props/default.rb
gamefic-3.2.0 lib/gamefic/props/default.rb