Class: Rubord::Embed
- Inherits:
-
Object
- Object
- Rubord::Embed
- Defined in:
- lib/rubord/models/embed.rb
Instance Attribute Summary collapse
-
#author(name:, url: nil, icon_url: nil) ⇒ Object
Returns the value of attribute author.
-
#color(hex) ⇒ Object
Returns the value of attribute color.
-
#description(text) ⇒ Object
Returns the value of attribute description.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#footer(text:, icon_url: nil) ⇒ Object
Returns the value of attribute footer.
-
#image(url) ⇒ Object
Returns the value of attribute image.
-
#thumbnail(url) ⇒ Object
Returns the value of attribute thumbnail.
-
#timestamp(time = Time.now) ⇒ Object
Returns the value of attribute timestamp.
-
#title(text) ⇒ Object
Returns the value of attribute title.
-
#url(link) ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #add_field(name, value, inline = false) ⇒ Object
-
#initialize ⇒ Embed
constructor
A new instance of Embed.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Embed
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 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 |
#fields ⇒ Object
Returns the value of attribute fields.
3 4 5 |
# File 'lib/rubord/models/embed.rb', line 3 def fields @fields end |
#footer(text:, icon_url: nil) ⇒ Object
Returns the value of attribute footer.
3 4 5 |
# File 'lib/rubord/models/embed.rb', line 3 def @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 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_h ⇒ Object
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 |