Class: BlockKit::Composition::Text

Inherits:
Base
  • Object
show all
Defined in:
lib/block_kit/composition/text.rb

Direct Known Subclasses

Mrkdwn, PlainText

Constant Summary collapse

MAX_LENGTH =
3000

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, fix, #fix_validation_errors, #fix_validation_errors!, fixes, #initialize, inspect, #inspect, #pretty_print, #to_json

Constructor Details

This class inherits a constructor from BlockKit::Base

Class Method Details

.inherited(subclass) ⇒ Object



14
15
16
# File 'lib/block_kit/composition/text.rb', line 14

def self.inherited(subclass)
  subclass.attribute_fixers = attribute_fixers.deep_dup
end

Instance Method Details

#as_jsonObject



28
29
30
# File 'lib/block_kit/composition/text.rb', line 28

def as_json(*)
  super.merge(text: text)
end

#lengthObject



18
19
20
# File 'lib/block_kit/composition/text.rb', line 18

def length
  text&.length || 0
end

#truncateObject



22
23
24
25
26
# File 'lib/block_kit/composition/text.rb', line 22

def truncate(*)
  dup.tap do |copy|
    copy.text = text.truncate(*)
  end
end