Class: SlackMessage::Response
- Inherits:
-
Object
- Object
- SlackMessage::Response
- Defined in:
- lib/slack_message/response.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#original_response ⇒ Object
readonly
Returns the value of attribute original_response.
-
#profile_handle ⇒ Object
readonly
Returns the value of attribute profile_handle.
-
#scheduled_message_id ⇒ Object
readonly
Returns the value of attribute scheduled_message_id.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(api_response, profile_handle) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
- #marshal_dump ⇒ Object
- #marshal_load(data) ⇒ Object
- #scheduled? ⇒ Boolean
- #sent_to_user? ⇒ Boolean
Constructor Details
#initialize(api_response, profile_handle) ⇒ Response
Returns a new instance of Response.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/slack_message/response.rb', line 4 def initialize(api_response, profile_handle) @original_response = JSON.parse(api_response.body) @ok = @original_response["ok"] @channel = @original_response["channel"] @timestamp = @original_response["ts"] @scheduled_message_id = @original_response["scheduled_message_id"] @profile_handle = profile_handle end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
2 3 4 |
# File 'lib/slack_message/response.rb', line 2 def channel @channel end |
#original_response ⇒ Object (readonly)
Returns the value of attribute original_response.
2 3 4 |
# File 'lib/slack_message/response.rb', line 2 def original_response @original_response end |
#profile_handle ⇒ Object (readonly)
Returns the value of attribute profile_handle.
2 3 4 |
# File 'lib/slack_message/response.rb', line 2 def profile_handle @profile_handle end |
#scheduled_message_id ⇒ Object (readonly)
Returns the value of attribute scheduled_message_id.
2 3 4 |
# File 'lib/slack_message/response.rb', line 2 def @scheduled_message_id end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
2 3 4 |
# File 'lib/slack_message/response.rb', line 2 def @timestamp end |
Instance Method Details
#inspect ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/slack_message/response.rb', line 31 def inspect identifier = if scheduled? "scheduled_message_id=#{}" else "timestamp=#{}" end ok_msg = @ok ? "ok" : "error" "<SlackMessage::Response #{ok_msg} profile_handle=:#{profile_handle} channel=#{channel} #{identifier}>" end |
#marshal_dump ⇒ Object
15 16 17 |
# File 'lib/slack_message/response.rb', line 15 def marshal_dump [ @profile_handle, @channel, @timestamp, @original_response, @ok, @original_response ] end |
#marshal_load(data) ⇒ Object
19 20 21 |
# File 'lib/slack_message/response.rb', line 19 def marshal_load(data) @profile_handle, @channel, @timestamp, @original_response, @ok, @original_response = data end |
#scheduled? ⇒ Boolean
27 28 29 |
# File 'lib/slack_message/response.rb', line 27 def scheduled? !! end |
#sent_to_user? ⇒ Boolean
23 24 25 |
# File 'lib/slack_message/response.rb', line 23 def sent_to_user? channel =~ /^D.*/ # users are D for DM, channels start w/ C end |