Class: ChatBot::GroupMeParser

Inherits:
Object
  • Object
show all
Defined in:
lib/chatbot/groupme_parser.rb

Class Method Summary collapse

Class Method Details

.parse(raw_message) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/chatbot/groupme_parser.rb', line 4

def self.parse(raw_message)
  gm_msg = JSON.parse(raw_message)
  if (gm_msg["name"].nil?)
    raise ArgumentError, "Invalid GroupMe message"
  end
  return GroupMeMessage.new(gm_msg["text"], gm_msg["name"], gm_msg["user_id"])
end