Class: Telegem::Types::User
Constant Summary collapse
- COMMON_FIELDS =
%w[id is_bot first_name last_name username can_join_groups can_read_all_group_messages supports_inline_queries language_code is_premium added_to_attachment_menu can_connect_to_business can_manage_bots supports_guest_queries].freeze
Instance Attribute Summary
Attributes inherited from BaseType
Instance Method Summary collapse
- #full_name ⇒ Object
-
#initialize(data) ⇒ User
constructor
A new instance of User.
- #mention ⇒ Object
- #to_s ⇒ Object
Methods inherited from BaseType
#inspect, #method_missing, #respond_to_missing?, #to_h
Constructor Details
#initialize(data) ⇒ User
Returns a new instance of User.
94 95 96 97 98 99 100 |
# File 'lib/api/types.rb', line 94 def initialize(data) super(data) COMMON_FIELDS.each do |field| define_accessor(field.to_sym) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Telegem::Types::BaseType
Instance Method Details
#full_name ⇒ Object
102 103 104 |
# File 'lib/api/types.rb', line 102 def full_name [first_name, last_name].compact.join(' ') end |
#mention ⇒ Object
106 107 108 109 110 111 112 113 114 |
# File 'lib/api/types.rb', line 106 def mention if username "@#{username}" elsif first_name first_name else "User ##{id}" end end |
#to_s ⇒ Object
116 117 118 |
# File 'lib/api/types.rb', line 116 def to_s full_name end |