Class: Discordrb::TimestampMarkdown
- Inherits:
-
Object
- Object
- Discordrb::TimestampMarkdown
- Defined in:
- lib/discordrb/data/timestamp.rb
Overview
A timestamp referenced in a message via markdown.
Constant Summary collapse
- STYLES =
Mapping of timestamp styles.
{ short_time: 't', # 16:20 long_time: 'T', # 16:20:30 short_date: 'd', # 20/04/2021 long_date: 'D', # 20 April 2021 short_datetime: 'f', # 20 April 2021 16:20 long_datetime: 'F', # Tuesday, 20 April 2021 16:20 relative: 'R', # 2 months ago simple_datetime: 's', # 20/04/2021, 16:20 medium_datetime: 'S' # 20/04/2021, 16:20:30 }.freeze
Instance Attribute Summary collapse
-
#time ⇒ Time
readonly
The time that the timestamp is referencing.
Instance Method Summary collapse
-
#long_date? ⇒ true, false
Whether or not the timestamp is displayed in a format such as
20 April 2021. -
#long_datetime? ⇒ true, false
Whether or not the timestamp is displayed in a format such as
Tuesday, 20 April 2021 16:20. -
#long_time? ⇒ true, false
Whether or not the timestamp is displayed in a format such as
16:20:30. -
#medium_datetime? ⇒ true, false
Whether or not the timestamp is displayed in a format such as
20/04/2021, 16:20:30. -
#relative? ⇒ true, false
Whether or not the timestamp is displayed in a format such as
2 months ago. -
#short_date? ⇒ true, false
Whether or not the timestamp is displayed in a format such as
20/04/2021. -
#short_datetime? ⇒ true, false
Whether or not the timestamp is displayed in a format such as
20 April 2021 16:20. -
#short_time? ⇒ true, false
Whether or not the timestamp is displayed in a format such as
16:20. -
#simple_datetime? ⇒ true, false
Whether or not the timestamp is displayed in a format such as
20/04/2021, 16:20. -
#style ⇒ String
Get the specifier used to determine the style of the timestamp.
-
#to_s ⇒ String
Get a string that will allow you to display the time in the Discord client.
Instance Attribute Details
#time ⇒ Time (readonly)
Returns the time that the timestamp is referencing.
20 21 22 |
# File 'lib/discordrb/data/timestamp.rb', line 20 def time @time end |
Instance Method Details
#long_date? ⇒ true, false
Returns whether or not the timestamp is displayed in a format such as 20 April 2021.
63 64 65 66 67 |
# File 'lib/discordrb/data/timestamp.rb', line 63 STYLES.each do |name, value| define_method("#{name}?") do style == value end end |
#long_datetime? ⇒ true, false
Returns whether or not the timestamp is displayed in a format such as Tuesday, 20 April 2021 16:20.
63 64 65 66 67 |
# File 'lib/discordrb/data/timestamp.rb', line 63 STYLES.each do |name, value| define_method("#{name}?") do style == value end end |
#long_time? ⇒ true, false
Returns whether or not the timestamp is displayed in a format such as 16:20:30.
63 64 65 66 67 |
# File 'lib/discordrb/data/timestamp.rb', line 63 STYLES.each do |name, value| define_method("#{name}?") do style == value end end |
#medium_datetime? ⇒ true, false
Returns whether or not the timestamp is displayed in a format such as 20/04/2021, 16:20:30.
63 64 65 66 67 |
# File 'lib/discordrb/data/timestamp.rb', line 63 STYLES.each do |name, value| define_method("#{name}?") do style == value end end |
#relative? ⇒ true, false
Returns whether or not the timestamp is displayed in a format such as 2 months ago.
63 64 65 66 67 |
# File 'lib/discordrb/data/timestamp.rb', line 63 STYLES.each do |name, value| define_method("#{name}?") do style == value end end |
#short_date? ⇒ true, false
Returns whether or not the timestamp is displayed in a format such as 20/04/2021.
63 64 65 66 67 |
# File 'lib/discordrb/data/timestamp.rb', line 63 STYLES.each do |name, value| define_method("#{name}?") do style == value end end |
#short_datetime? ⇒ true, false
Returns whether or not the timestamp is displayed in a format such as 20 April 2021 16:20.
63 64 65 66 67 |
# File 'lib/discordrb/data/timestamp.rb', line 63 STYLES.each do |name, value| define_method("#{name}?") do style == value end end |
#short_time? ⇒ true, false
Returns whether or not the timestamp is displayed in a format such as 16:20.
63 64 65 66 67 |
# File 'lib/discordrb/data/timestamp.rb', line 63 STYLES.each do |name, value| define_method("#{name}?") do style == value end end |
#simple_datetime? ⇒ true, false
Returns whether or not the timestamp is displayed in a format such as 20/04/2021, 16:20.
63 64 65 66 67 |
# File 'lib/discordrb/data/timestamp.rb', line 63 STYLES.each do |name, value| define_method("#{name}?") do style == value end end |
#style ⇒ String
Get the specifier used to determine the style of the timestamp.
30 31 32 |
# File 'lib/discordrb/data/timestamp.rb', line 30 def style @style || 'f' end |