Class: Discorb::SelectMenu::Option
- Inherits:
-
Object
- Object
- Discorb::SelectMenu::Option
- Defined in:
- lib/discorb/components.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.
-
#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.
256 257 258 259 260 261 262 |
# File 'lib/discorb/components.rb', line 256 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.
246 247 248 |
# File 'lib/discorb/components.rb', line 246 def default @default end |
#description -> String
Returns The description of the option.
242 243 244 |
# File 'lib/discorb/components.rb', line 242 def description @description end |
#emoji -> Discorb::Emoji
Returns The emoji of the option.
244 245 246 |
# File 'lib/discorb/components.rb', line 244 def emoji @emoji end |
#label -> String
Returns The label of the option.
238 239 240 |
# File 'lib/discorb/components.rb', line 238 def label @label end |
#value -> String
Returns The value of the option.
240 241 242 |
# File 'lib/discorb/components.rb', line 240 def value @value end |
Class Method Details
.from_hash(data) -> Discorb::SelectMenu::Option
Creates a new option from a hash.
306 307 308 |
# File 'lib/discorb/components.rb', line 306 def from_hash(data) new(data[:label], data[:value], description: data[:description], emoji: data[:emoji], default: data[:default]) end |
Instance Method Details
#to_hash -> Hash
Converts the option to a hash.
270 271 272 273 274 275 276 277 278 |
# File 'lib/discorb/components.rb', line 270 def to_hash { label: @label, value: @value, description: @description, emoji: hash_emoji(@emoji), default: @default, } end |