Class: Rubord::Embed

Inherits:
Object
  • Object
show all
Defined in:
lib/rubord/models/embed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEmbed

Returns a new instance of Embed.



14
15
16
# File 'lib/rubord/models/embed.rb', line 14

def initialize
  @fields = []
end

Instance Attribute Details

#author(name:, url: nil, icon_url: nil) ⇒ Object

Returns the value of attribute author.



3
4
5
# File 'lib/rubord/models/embed.rb', line 3

def author
  @author
end

#color(hex) ⇒ Object

Returns the value of attribute color.



3
4
5
# File 'lib/rubord/models/embed.rb', line 3

def color
  @color
end

#description(text) ⇒ Object

Returns the value of attribute description.



3
4
5
# File 'lib/rubord/models/embed.rb', line 3

def description
  @description
end

#fieldsObject

Returns the value of attribute fields.



3
4
5
# File 'lib/rubord/models/embed.rb', line 3

def fields
  @fields
end

Returns the value of attribute footer.



3
4
5
# File 'lib/rubord/models/embed.rb', line 3

def footer
  @footer
end

#image(url) ⇒ Object

Returns the value of attribute image.



3
4
5
# File 'lib/rubord/models/embed.rb', line 3

def image
  @image
end

#thumbnail(url) ⇒ Object

Returns the value of attribute thumbnail.



3
4
5
# File 'lib/rubord/models/embed.rb', line 3

def thumbnail
  @thumbnail
end

#timestamp(time = Time.now) ⇒ Object

Returns the value of attribute timestamp.



3
4
5
# File 'lib/rubord/models/embed.rb', line 3

def timestamp
  @timestamp
end

#title(text) ⇒ Object

Returns the value of attribute title.



3
4
5
# File 'lib/rubord/models/embed.rb', line 3

def title
  @title
end

#url(link) ⇒ Object

Returns the value of attribute url.



3
4
5
# File 'lib/rubord/models/embed.rb', line 3

def url
  @url
end

Instance Method Details

#add_field(name, value, inline = false) ⇒ Object



63
64
65
66
# File 'lib/rubord/models/embed.rb', line 63

def add_field(name, value, inline = false)
  @fields << { name: name, value: value, inline: inline }
  self
end

#to_hObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/rubord/models/embed.rb', line 68

def to_h
  {
    title: @title,
    description: @description,
    url: @url,
    timestamp: @timestamp,
    color: @color,
    footer: @footer,
    image: @image,
    thumbnail: @thumbnail,
    author: @author,
    fields: @fields.empty? ? nil : @fields
  }.compact
end