Class: MijDiscord::Data::Embed

Inherits:
Object
  • Object
show all
Defined in:
lib/mij-discord/data/embed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Embed

Returns a new instance of Embed.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mij-discord/data/embed.rb', line 31

def initialize(data)
  @type, @url = data['type'], data['url']
  @title, @description = data['title'], data['description']

  @color = ColorRGB.new(data['color']) if data['color']
  @timestamp = Time.parse(data['timestamp']).utc if data['timestamp']

  @footer = EmbedFooter.new(data['footer']) if data['footer']
  @thumbnail = EmbedMedia.new(data['thumbnail']) if data['thumbnail']

  @image = EmbedMedia.new(data['image']) if data['image']
  @video = EmbedMedia.new(data['video']) if data['video']

  @author = EmbedAuthor.new(data['author']) if data['author']
  @provider = EmbedProvider.new(data['provider']) if data['provider']

  @fields = data['fields']&.map {|x| EmbedField.new(x) }
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



27
28
29
# File 'lib/mij-discord/data/embed.rb', line 27

def author
  @author
end

#colorObject (readonly)

Returns the value of attribute color.



15
16
17
# File 'lib/mij-discord/data/embed.rb', line 15

def color
  @color
end

#descriptionObject (readonly)

Returns the value of attribute description.



9
10
11
# File 'lib/mij-discord/data/embed.rb', line 9

def description
  @description
end

#fieldsObject (readonly)

Returns the value of attribute fields.



29
30
31
# File 'lib/mij-discord/data/embed.rb', line 29

def fields
  @fields
end

Returns the value of attribute footer.



17
18
19
# File 'lib/mij-discord/data/embed.rb', line 17

def footer
  @footer
end

#imageObject (readonly)

Returns the value of attribute image.



21
22
23
# File 'lib/mij-discord/data/embed.rb', line 21

def image
  @image
end

#providerObject (readonly)

Returns the value of attribute provider.



25
26
27
# File 'lib/mij-discord/data/embed.rb', line 25

def provider
  @provider
end

#thumbnailObject (readonly)

Returns the value of attribute thumbnail.



19
20
21
# File 'lib/mij-discord/data/embed.rb', line 19

def thumbnail
  @thumbnail
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



13
14
15
# File 'lib/mij-discord/data/embed.rb', line 13

def timestamp
  @timestamp
end

#titleObject (readonly)

Returns the value of attribute title.



7
8
9
# File 'lib/mij-discord/data/embed.rb', line 7

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/mij-discord/data/embed.rb', line 5

def type
  @type
end

#urlObject (readonly)

Returns the value of attribute url.



11
12
13
# File 'lib/mij-discord/data/embed.rb', line 11

def url
  @url
end

#videoObject (readonly)

Returns the value of attribute video.



23
24
25
# File 'lib/mij-discord/data/embed.rb', line 23

def video
  @video
end