Class: Flowpi::Message
- Inherits:
-
Object
- Object
- Flowpi::Message
- Defined in:
- lib/flowpi.rb
Constant Summary collapse
- MESSAGE_TYPES =
%w(message comment)
Instance Method Summary collapse
- #content ⇒ Object
- #has_content? ⇒ Boolean
-
#initialize(data = {}) ⇒ Message
constructor
A new instance of Message.
- #parse(line) ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Message
Returns a new instance of Message.
58 59 60 |
# File 'lib/flowpi.rb', line 58 def initialize(data = {}) @data = data end |
Instance Method Details
#content ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/flowpi.rb', line 71 def content if @data['content'].kind_of?(Hash) content = @data['content']['text'] else content = @data['content'] end content.gsub(/[^a-z ]/i, '') end |
#has_content? ⇒ Boolean
62 63 64 |
# File 'lib/flowpi.rb', line 62 def has_content? MESSAGE_TYPES.include?(@data['event']) end |
#parse(line) ⇒ Object
66 67 68 69 |
# File 'lib/flowpi.rb', line 66 def parse(line) @data = JSON.parse(line) self end |