Class: Chat
- Inherits:
-
Object
- Object
- Chat
- Defined in:
- lib/telegram/chat.rb
Overview
Is a representation of Telegrams Chat object
Instance Attribute Summary collapse
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, type:, title: nil, username: nil, first_name: nil, last_name: nil) ⇒ Chat
constructor
A new instance of Chat.
- #reply(text, opts = {}) ⇒ Object
Constructor Details
#initialize(id:, type:, title: nil, username: nil, first_name: nil, last_name: nil) ⇒ Chat
Returns a new instance of Chat.
13 14 15 16 17 18 19 20 |
# File 'lib/telegram/chat.rb', line 13 def initialize(id:, type:, title: nil, username: nil, first_name: nil, last_name: nil) @id = id @type = type @title = title @username = username @first_name = first_name @last_name = last_name end |
Instance Attribute Details
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
5 6 7 |
# File 'lib/telegram/chat.rb', line 5 def first_name @first_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/telegram/chat.rb', line 5 def id @id end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
5 6 7 |
# File 'lib/telegram/chat.rb', line 5 def last_name @last_name end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/telegram/chat.rb', line 5 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/telegram/chat.rb', line 5 def type @type end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
5 6 7 |
# File 'lib/telegram/chat.rb', line 5 def username @username end |
Class Method Details
.from_hash(chat) ⇒ Object
7 8 9 10 11 |
# File 'lib/telegram/chat.rb', line 7 def self.from_hash(chat) return nil unless chat.is_a? Hash Chat.new(id: chat['id'], type: chat['type'], title: chat['title'], username: chat['username'], first_name: chat['first_name'], last_name: chat['last_name']) end |
Instance Method Details
#reply(text, opts = {}) ⇒ Object
22 23 24 |
# File 'lib/telegram/chat.rb', line 22 def reply(text, opts = {}) Telegram.sendMessage opts.merge(chat_id: id, text: text) end |