Sha256: 04f3717ea9bb038c3929ae17b3879dcba3073c81c4577298e7284fd15043a861

Contents?: true

Size: 624 Bytes

Versions: 5

Compression:

Stored size: 624 Bytes

Contents

module Ellen
  class Message
    attr_reader(
      :match_data,
      :original,
    )

    def initialize(original)
      @original = original
    end

    def body
      @original[:body]
    end

    def from
      @original[:from]
    end

    def robot
      @original[:robot]
    end

    def to
      @original[: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: to, to: from, original: original }.merge(options)
      robot.say(attributes)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ellen-0.2.6 lib/ellen/message.rb
ellen-0.2.5 lib/ellen/message.rb
ellen-0.2.4 lib/ellen/message.rb
ellen-0.2.3 lib/ellen/message.rb
ellen-0.2.2 lib/ellen/message.rb