Class: Discorb::SelectMenu
- Defined in:
- lib/discorb/components.rb
Overview
Represents a select menu component.
Defined Under Namespace
Classes: Option
Instance Attribute Summary collapse
-
#custom_id -> String
The custom ID of the select menu.
-
#disabled -> Boolean
(also: #disabled?)
Whether the select menu is disabled.
-
#max_values -> Integer
The maximum number of values.
-
#min_values -> Integer
The minimum number of values.
-
#options -> Array<SelectMenu::Option>
The options of the select menu.
Instance Method Summary collapse
-
#initialize(custom_id, options, placeholder: nil, min_values: 1, max_values: 1) -> SelectMenu
constructor
Initialize a new select menu.
- #inspect -> Object
-
#to_hash -> Hash
Converts the select menu to a hash.
Methods inherited from Component
Constructor Details
#initialize(custom_id, options, placeholder: nil, min_values: 1, max_values: 1) -> SelectMenu
Initialize a new select menu.
203 204 205 206 207 208 209 |
# File 'lib/discorb/components.rb', line 203 def initialize(custom_id, , placeholder: nil, min_values: 1, max_values: 1) @custom_id = custom_id @options = @placeholder = placeholder @min_values = min_values @max_values = max_values end |
Instance Attribute Details
#custom_id -> String
Returns The custom ID of the select menu.
183 184 185 |
# File 'lib/discorb/components.rb', line 183 def custom_id @custom_id end |
#disabled -> Boolean Also known as: disabled?
Returns Whether the select menu is disabled.
191 192 193 |
# File 'lib/discorb/components.rb', line 191 def disabled @disabled end |
#max_values -> Integer
Returns The maximum number of values.
189 190 191 |
# File 'lib/discorb/components.rb', line 189 def max_values @max_values end |
#min_values -> Integer
Returns The minimum number of values.
187 188 189 |
# File 'lib/discorb/components.rb', line 187 def min_values @min_values end |
#options -> Array<SelectMenu::Option>
Returns The options of the select menu.
185 186 187 |
# File 'lib/discorb/components.rb', line 185 def @options end |
Instance Method Details
#inspect -> Object
229 230 231 |
# File 'lib/discorb/components.rb', line 229 def inspect "#<#{self.class}: #{@custom_id}>" end |
#to_hash -> Hash
Converts the select menu to a hash.
217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/discorb/components.rb', line 217 def to_hash { type: 3, custom_id: @custom_id, options: @options.map(&:to_hash), placeholder: @placeholder, min_values: @min_values, max_values: @max_values, disabled: @disabled, } end |