Class: Intelligence::MessageContent::Text

Inherits:
Base
  • Object
show all
Defined in:
lib/intelligence/message_content/text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Intelligence::MessageContent::Base

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



10
11
12
# File 'lib/intelligence/message_content/text.rb', line 10

def text
  @text
end

Instance Method Details

#merge(other) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/intelligence/message_content/text.rb', line 16

def merge( other )
  other_text = other.text
  text = @text 
  text = ( @text || '' ) + other_text if other_text

  self.class.new( text: text )
end

#to_hObject



24
25
26
# File 'lib/intelligence/message_content/text.rb', line 24

def to_h
  { type: :text, text: text }
end

#valid?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/intelligence/message_content/text.rb', line 12

def valid?
  ( text || false ) && text.respond_to?( :empty? ) && !text.empty? 
end