Sha256: cfbde1612719c4e5370f70acfd44026c68b075533c13f5b4133616c71e2c53a9

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require "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
      interpret_conversation(response)
    end

    def interpret_conversation(response)
      response
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
converse-1.0.4 lib/converse/interaction.rb