Class: Telegem::Types::BaseType
- Inherits:
-
Object
- Object
- Telegem::Types::BaseType
show all
- Defined in:
- lib/api/types.rb
Direct Known Subclasses
Animation, Audio, BotCommand, BotCommandScope, CallbackQuery, Chat, ChatAdministratorRights, ChatInviteLink, ChatJoinRequest, ChatMember, ChatMemberUpdated, ChatPermissions, ChatPhoto, ChosenInlineResult, Contact, Dice, Document, File, ForumTopicClosed, ForumTopicCreated, ForumTopicEdited, ForumTopicReopened, GeneralForumTopicHidden, GeneralForumTopicUnhidden, InlineQuery, InlineQueryResult, Invoice, Location, MaskPosition, Message, MessageAutoDeleteTimerChanged, MessageEntity, OrderInfo, PassportData, PhotoSize, Poll, PollAnswer, PollOption, PreCheckoutQuery, ProximityAlertTriggered, ResponseParameters, ShippingAddress, ShippingQuery, Sticker, StickerSet, SuccessfulPayment, Update, User, UserProfileAudios, UserProfilePhotos, Venue, Video, VideoChatEnded, VideoChatLocation, VideoChatParticipantsInvited, VideoChatScheduled, VideoChatStarted, VideoNote, Voice, WebAppData, WebhookInfo, WriteAccessAllowed
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ BaseType
Returns a new instance of BaseType.
4
5
6
7
|
# File 'lib/api/types.rb', line 4
def initialize(data)
@_raw_data = data || {}
@_accessors_defined = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/api/types.rb', line 9
def method_missing(name, *args)
return super if args.any? || block_given?
define_accessor(name)
if respond_to?(name)
send(name)
else
super
end
end
|
Instance Attribute Details
#_raw_data ⇒ Object
Returns the value of attribute _raw_data.
41
42
43
|
# File 'lib/api/types.rb', line 41
def _raw_data
@_raw_data
end
|
Instance Method Details
#inspect ⇒ Object
33
34
35
|
# File 'lib/api/types.rb', line 33
def inspect
"#<#{self.class.name} #{@_raw_data.inspect}>"
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
21
22
23
24
25
|
# File 'lib/api/types.rb', line 21
def respond_to_missing?(name, include_private = false)
key = name.to_s
camel_key = snake_to_camel(key)
@_raw_data.key?(key) || @_raw_data.key?(camel_key) || super
end
|
#to_h ⇒ Object
Also known as:
to_hash
27
28
29
|
# File 'lib/api/types.rb', line 27
def to_h
@_raw_data.dup
end
|
#to_s ⇒ Object
37
38
39
|
# File 'lib/api/types.rb', line 37
def to_s
inspect
end
|