Class: Telegem::Types::User

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

Instance Attribute Summary collapse

Attributes inherited from BaseType

#_raw_data

Instance Method Summary collapse

Methods inherited from BaseType

#method_missing, #respond_to_missing?

Constructor Details

#initialize(data) ⇒ User

Returns a new instance of User.



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/api/types.rb', line 37

def initialize(data)
  super(data)
  
  @id = data['id']
  @is_bot = data['is_bot']
  @first_name = data['first_name']
  @last_name = data['last_name']
  @username = data['username']
  @can_join_groups = data['can_join_groups']
  @can_read_all_group_messages = data['can_read_all_group_messages']
  @supports_inline_queries = data['supports_inline_queries']
end

Dynamic Method Handling

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

Instance Attribute Details

#can_join_groupsObject (readonly)

Returns the value of attribute can_join_groups.



34
35
36
# File 'lib/api/types.rb', line 34

def can_join_groups
  @can_join_groups
end

#can_read_all_group_messagesObject (readonly)

Returns the value of attribute can_read_all_group_messages.



34
35
36
# File 'lib/api/types.rb', line 34

def can_read_all_group_messages
  @can_read_all_group_messages
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



34
35
36
# File 'lib/api/types.rb', line 34

def first_name
  @first_name
end

#idObject (readonly)

Returns the value of attribute id.



34
35
36
# File 'lib/api/types.rb', line 34

def id
  @id
end

#is_botObject (readonly)

Returns the value of attribute is_bot.



34
35
36
# File 'lib/api/types.rb', line 34

def is_bot
  @is_bot
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



34
35
36
# File 'lib/api/types.rb', line 34

def last_name
  @last_name
end

#supports_inline_queriesObject (readonly)

Returns the value of attribute supports_inline_queries.



34
35
36
# File 'lib/api/types.rb', line 34

def supports_inline_queries
  @supports_inline_queries
end

#usernameObject (readonly)

Returns the value of attribute username.



34
35
36
# File 'lib/api/types.rb', line 34

def username
  @username
end

Instance Method Details

#full_nameObject



50
51
52
# File 'lib/api/types.rb', line 50

def full_name
  [first_name, last_name].compact.join(' ')
end

#mentionObject



54
55
56
# File 'lib/api/types.rb', line 54

def mention
  username ? "@#{username}" : first_name
end