Sha256: 6807e38997a27d66434be56a89065be4cac5500bcb99be16c7c54250a1920af0

Contents?: true

Size: 495 Bytes

Versions: 3

Compression:

Stored size: 495 Bytes

Contents

module Attentive
  class Match
    attr_reader :listener, :phrase, :message

    def initialize(phrase, attributes={})
      @phrase = phrase.to_s
      @match_data = attributes.fetch(:match_data, {})
      @listener = attributes[:listener]
      @message = attributes[:message]
    end

    def matched?(variable_name)
      @match_data.key? variable_name.to_s
    end

    def [](variable_name)
      @match_data.fetch variable_name.to_s
    end

    def to_s
      @phrase
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
attentive-0.2.0 lib/attentive/match.rb
attentive-0.1.1 lib/attentive/match.rb
attentive-0.1.0 lib/attentive/match.rb