Sha256: 31e8e457fe815c21c4a0ba9c24c4446aa1a31d037aac8ffcc182685257898337

Contents?: true

Size: 546 Bytes

Versions: 2

Compression:

Stored size: 546 Bytes

Contents

module Ellen
  class Message
    attr_reader(
      :body,
      :from,
      :match_data,
      :robot,
      :to,
    )

    def initialize(options)
      @body = options[:body]
      @from = options[:from]
      @robot = options[:robot]
      @to = options[:to]
    end

    def match(pattern)
      @match_data = pattern.match(body)
    end

    def [](index)
      match_data[index]
    end

    def reply(body, options = {})
      attributes = { body: body, from: from, to: to }.merge(options)
      robot.say(attributes)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ellen-0.2.1 lib/ellen/message.rb
ellen-0.2.0 lib/ellen/message.rb