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.
97 98 99 100 101 102 103 |
# File 'lib/api/types.rb', line 97 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
105 106 107 |
# File 'lib/api/types.rb', line 105 def full_name [first_name, last_name].compact.join(' ') end |
#mention ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/api/types.rb', line 109 def mention if username "@#{username}" elsif first_name first_name else "User ##{id}" end end |
#to_s ⇒ Object
119 120 121 |
# File 'lib/api/types.rb', line 119 def to_s full_name end |