Class: S3PO::Event
- Inherits:
-
Object
- Object
- S3PO::Event
- Defined in:
- lib/s-3po/events.rb
Overview
Base event class; a generic event class should only come from Slack.
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #channel ⇒ Object
- #channel=(string) ⇒ Object
-
#initialize(event = {}) ⇒ Event
constructor
A new instance of Event.
-
#is_message? ⇒ Boolean
Is it a message event?.
-
#is_simplemessage? ⇒ Boolean
Is it a simple message event; a straight forward text message without a subtype?.
- #subtype ⇒ Symbol
- #ts ⇒ Object
- #type ⇒ Symbol
- #user ⇒ Object
Constructor Details
#initialize(event = {}) ⇒ Event
Returns a new instance of Event.
8 9 10 11 |
# File 'lib/s-3po/events.rb', line 8 def initialize(event = {}) fail 'Must be a Hash.' unless event.class == Hash @object = event end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
6 7 8 |
# File 'lib/s-3po/events.rb', line 6 def object @object end |
Instance Method Details
#channel ⇒ Object
42 43 44 |
# File 'lib/s-3po/events.rb', line 42 def channel object[:channel] end |
#channel=(string) ⇒ Object
46 47 48 49 50 |
# File 'lib/s-3po/events.rb', line 46 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_message? ⇒ Boolean
Is it a message event?
22 23 24 |
# File 'lib/s-3po/events.rb', line 22 def return !type.nil? && type == :message end |
#is_simplemessage? ⇒ Boolean
Is it a simple message event; a straight forward text message without a subtype?
34 35 36 |
# File 'lib/s-3po/events.rb', line 34 def && subtype.nil? end |
#subtype ⇒ Symbol
27 28 29 30 |
# File 'lib/s-3po/events.rb', line 27 def subtype return object[:subtype].to_sym if object[:subtype] return nil end |
#ts ⇒ Object
52 53 54 |
# File 'lib/s-3po/events.rb', line 52 def ts object[:ts] end |
#type ⇒ Symbol
14 15 16 17 18 |
# File 'lib/s-3po/events.rb', line 14 def type return :response unless object[:ok].nil? return object[:type].to_sym if object[:type] return nil end |
#user ⇒ Object
38 39 40 |
# File 'lib/s-3po/events.rb', line 38 def user object[:user] end |