Class: Telegem::Types::CallbackQuery

Inherits:
BaseType
  • Object
show all
Defined in:
lib/api/types.rb

Constant Summary collapse

COMMON_FIELDS =
%w[id from message inline_message_id chat_instance data game_short_name].freeze

Instance Attribute Summary

Attributes inherited from BaseType

#_raw_data

Instance Method Summary collapse

Methods inherited from BaseType

#inspect, #method_missing, #respond_to_missing?, #to_h, #to_s

Constructor Details

#initialize(data) ⇒ CallbackQuery

Returns a new instance of CallbackQuery.



374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/api/types.rb', line 374

def initialize(data)
  super(data)
  
  COMMON_FIELDS.each do |field|
    define_accessor(field.to_sym)
  end
  
  if @_raw_data['from'] && !@_raw_data['from'].is_a?(User)
    @_raw_data['from'] = User.new(@_raw_data['from'])
  end
  
  if @_raw_data['message'] && !@_raw_data['message'].is_a?(Message)
    @_raw_data['message'] = Message.new(@_raw_data['message'])
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Telegem::Types::BaseType

Instance Method Details

#from_user?Boolean

Returns:

  • (Boolean)


390
391
392
# File 'lib/api/types.rb', line 390

def from_user?
  !!from
end

#inline_message?Boolean

Returns:

  • (Boolean)


398
399
400
# File 'lib/api/types.rb', line 398

def inline_message?
  !!inline_message_id
end

#message?Boolean

Returns:

  • (Boolean)


394
395
396
# File 'lib/api/types.rb', line 394

def message?
  !!message
end