Class: Bot::Message::Base
- Inherits:
-
Object
- Object
- Bot::Message::Base
- Defined in:
- lib/bot/messages/base.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
- #as_json(options = nil) ⇒ Object
-
#initialize(to, options = false) ⇒ Base
constructor
A new instance of Base.
- #method_missing(m, *args, &block) ⇒ Object
Constructor Details
#initialize(to, options = false) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/bot/messages/base.rb', line 6 def initialize(to, =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.[m.to_s.gsub('=', '')] = arg end else self.[m.to_s] end end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/bot/messages/base.rb', line 4 def @message end |
Instance Method Details
#as_json(options = nil) ⇒ Object
10 11 12 |
# File 'lib/bot/messages/base.rb', line 10 def as_json(=nil) self..to_h end |