Class: Bot::Message::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/bot/messages/base.rb

Direct Known Subclasses

Card, Photo, Text, Video

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(to, options = false) ⇒ Base

Returns a new instance of Base.

Raises:

  • (NotImplementedError)


6
7
8
# File 'lib/bot/messages/base.rb', line 6

def initialize(to, options=false)
  raise NotImplementedError
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/bot/messages/base.rb', line 14

def method_missing(m, *args, &block)
  if m =~ /.+=/
    args.each do |arg|
      self.message[m.to_s.gsub('=', '')] = arg
    end
  else
    self.message[m.to_s]
  end
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/bot/messages/base.rb', line 4

def message
  @message
end

Instance Method Details

#as_json(options = nil) ⇒ Object



10
11
12
# File 'lib/bot/messages/base.rb', line 10

def as_json(options=nil)
  self.message.to_h
end