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