class S3PO::Event
Base event class; a generic event class should only come from Slack.
Attributes
object[R]
options[R]
Public Class Methods
new(event = {}, opts = {})
click to toggle source
# File lib/s-3po/events.rb, line 9 def initialize(event = {}, opts = {}) fail 'Must be a Hash.' unless event.class == Hash @object = event @options = opts end
Public Instance Methods
channel()
click to toggle source
# File lib/s-3po/events.rb, line 50 def channel object[:channel] end
channel=(string)
click to toggle source
# File lib/s-3po/events.rb, line 54 def channel=(string) fail 'Must be a String.' unless string.class == String fail 'Invalid channel' unless /[CD][0-9A-Z]+/ =~ string object[:channel] = string end
is_im?()
click to toggle source
Is is an IM, direct channel? @return [Boolean]
# File lib/s-3po/events.rb, line 46 def is_im? !object[:channel].nil? && channel.start_with?('D') end
is_message?()
click to toggle source
Is it a message event? @return [Boolean]
# File lib/s-3po/events.rb, line 24 def is_message? return !type.nil? && type == :message end
is_simplemessage?()
click to toggle source
Is it a simple message event; a straight forward text message without a subtype? @return [Boolean]
# File lib/s-3po/events.rb, line 36 def is_simplemessage? is_message? && subtype.nil? end
subtype()
click to toggle source
@return [Symbol]
# File lib/s-3po/events.rb, line 29 def subtype return object[:subtype].to_sym if object[:subtype] return nil end
ts()
click to toggle source
# File lib/s-3po/events.rb, line 60 def ts object[:ts] end
type()
click to toggle source
@return [Symbol]
# File lib/s-3po/events.rb, line 16 def type return :response unless object[:ok].nil? return object[:type].to_sym if object[:type] return nil end
user()
click to toggle source
# File lib/s-3po/events.rb, line 40 def user object[:user] end