Class: Discorb::SelectMenu::Option
- Inherits:
-
Object
- Object
- Discorb::SelectMenu::Option
- Defined in:
- lib/discorb/components/select_menu.rb
Overview
Represents an option of a select menu.
Instance Attribute Summary collapse
-
#default -> Boolean
Whether the option is default.
-
#description -> String
The description of the option.
-
#emoji -> Discorb::Emoji
The emoji of the option.
-
#label -> String
The label of the option.
-
#value -> String
The value of the option.
Class Method Summary collapse
-
.from_hash(data) -> Discorb::SelectMenu::Option
Creates a new option from a hash.
Instance Method Summary collapse
-
#initialize(label, value, description: nil, emoji: nil, default: false) -> Option
constructor
Initialize a new option.
- #inspect -> Object
-
#to_hash -> Hash
Converts the option to a hash.
Constructor Details
#initialize(label, value, description: nil, emoji: nil, default: false) -> Option
Initialize a new option.
102 103 104 105 106 107 108 |
# File 'lib/discorb/components/select_menu.rb', line 102 def initialize(label, value, description: nil, emoji: nil, default: false) @label = label @value = value @description = description @emoji = emoji @default = default end |
Instance Attribute Details
#default -> Boolean
Returns Whether the option is default.
92 93 94 |
# File 'lib/discorb/components/select_menu.rb', line 92 def default @default end |
#description -> String
Returns The description of the option.
88 89 90 |
# File 'lib/discorb/components/select_menu.rb', line 88 def description @description end |
#emoji -> Discorb::Emoji
Returns The emoji of the option.
90 91 92 |
# File 'lib/discorb/components/select_menu.rb', line 90 def emoji @emoji end |
#label -> String
Returns The label of the option.
84 85 86 |
# File 'lib/discorb/components/select_menu.rb', line 84 def label @label end |
#value -> String
Returns The value of the option.
86 87 88 |
# File 'lib/discorb/components/select_menu.rb', line 86 def value @value end |
Class Method Details
.from_hash(data) -> Discorb::SelectMenu::Option
Creates a new option from a hash.
139 140 141 |
# File 'lib/discorb/components/select_menu.rb', line 139 def from_hash(data) new(data[:label], data[:value], description: data[:description], emoji: data[:emoji], default: data[:default]) end |
Instance Method Details
#inspect -> Object
127 128 129 |
# File 'lib/discorb/components/select_menu.rb', line 127 def inspect "#<#{self.class} #{@label}: #{@value}>" end |
#to_hash -> Hash
Converts the option to a hash.
117 118 119 120 121 122 123 124 125 |
# File 'lib/discorb/components/select_menu.rb', line 117 def to_hash { label: @label, value: @value, description: @description, emoji: @emoji&.to_hash, default: @default, } end |