Class: Update

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram/update.rb

Overview

Is a representation of Telegrams Update object

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(update_id:, message: nil, inline_query: nil, chosen_inline_result: nil) ⇒ Update

Returns a new instance of Update.



15
16
17
18
19
20
# File 'lib/telegram/update.rb', line 15

def initialize(update_id:, message: nil, inline_query: nil, chosen_inline_result: nil)
  @update_id = update_id
  @message = message
  @inline_query = inline_query
  @chosen_inline_result = chosen_inline_result
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/telegram/update.rb', line 5

def message
  @message
end

Class Method Details

.from_hash(update) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/telegram/update.rb', line 7

def self.from_hash(update)
  return nil unless update.is_a? Hash

  message = Message.from_hash update['message']

  Update.new(update_id: update['update_id'], message: message)
end