Class: Slack::BlockKit::CompositionObjects::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/slack/block_kit/composition_objects/option.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/slack/block_kit/composition_objects/option.rb', line 8

def description
  @description
end

#textObject

Returns the value of attribute text.



8
9
10
# File 'lib/slack/block_kit/composition_objects/option.rb', line 8

def text
  @text
end

#urlObject

Returns the value of attribute url.



8
9
10
# File 'lib/slack/block_kit/composition_objects/option.rb', line 8

def url
  @url
end

#valueObject

Returns the value of attribute value.



8
9
10
# File 'lib/slack/block_kit/composition_objects/option.rb', line 8

def value
  @value
end

Class Method Details

.[](hash) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/slack/block_kit/composition_objects/option.rb', line 10

def self.[](hash)
  new.tap do |object|
    object.text = hash.fetch(:text)
    object.value = hash.fetch(:value)
    object.description = hash[:description] if hash.key?(:description)
    object.url = hash[:url] if hash.key?(:url)
  end
end

Instance Method Details

#to_hObject



48
49
50
51
52
53
# File 'lib/slack/block_kit/composition_objects/option.rb', line 48

def to_h
  { text: text.to_h,
    value: value,
    description: description&.to_h,
    url: url }.compact
end