Sha256: 3d04a23a434c4d98d575dca061215a0ad895cb5a98bb778bb05586ba8e8f4764

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require "converse/comms/simple_logger"

module Converse

  class Interaction
    attr_accessor :broker
    attr_accessor :concern
    attr_accessor :action
    attr_accessor :substance
    attr_accessor :conversation
    attr_accessor :should_i_ask

    def discuss_with_broker_concerning(broker, concern)
      discuss_with(broker)
      concerning(concern)
    end

    def discuss_with(broker)
      @broker = broker
    end

    def concerning(concern)
      @concern = concern.dup
    end

    def about(action)
      @action = action.dup
    end

    def detailed_by(substance)
      @substance = substance
    end

    def by_asking
      @should_i_ask = true
    end

    def by_saying
      @should_i_ask = false
    end

    def ask
      @conversation.ask
    end

    def say
      @conversation.say
    end

    def discuss
      @conversation = broker.broker_conversation(@broker.open_topic(@concern, @action))
      @conversation.subscribe(SimpleLogger.new)
      @should_i_ask ? response = ask : response = say
      translated_response = broker.translate_response(response)
      interpret_conversation(translated_response)
    end

    def interpret_conversation(response)
      response
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
converse-1.0.10 lib/converse/interaction.rb
converse-1.0.9 lib/converse/interaction.rb