Class: Hahamut::Message::Base

Inherits:
Object
  • Object
show all
Includes:
Support::Attributes
Defined in:
lib/hahamut/message/base.rb

Overview

Abstract Message

Direct Known Subclasses

BotEvent, BotStart, Command, Image, Sticker, Text

Instance Attribute Summary collapse

Attributes included from Support::Attributes

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Support::Attributes

#assign_attributes, included

Constructor Details

#initialize(attributes, sender_id = nil) ⇒ Base

TODO: Improve sender / recipient setup



18
19
20
21
# File 'lib/hahamut/message/base.rb', line 18

def initialize(attributes, sender_id = nil)
  assign_attributes(attributes)
  @sender_id = sender_id
end

Instance Attribute Details

#sender_idObject (readonly)

Returns the value of attribute sender_id.



15
16
17
# File 'lib/hahamut/message/base.rb', line 15

def sender_id
  @sender_id
end

Class Method Details

.match?(_message) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/hahamut/message/base.rb', line 8

def match?(_message)
  false
end

Instance Method Details

#as_json(_obj = nil) ⇒ Object



27
28
29
# File 'lib/hahamut/message/base.rb', line 27

def as_json(_obj = nil)
  @attributes.dup.merge(type: type)
end

#to_json(_obj = nil) ⇒ Object



31
32
33
# File 'lib/hahamut/message/base.rb', line 31

def to_json(_obj = nil)
  as_json.to_json
end

#typeObject

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/hahamut/message/base.rb', line 23

def type
  raise NotImplementedError
end