Class: Ask::Content::Text

Inherits:
Object
  • Object
show all
Includes:
Block
Defined in:
lib/ask/content.rb

Overview

A text block within a multi-modal message.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Block

#inspect

Constructor Details

#initialize(text) ⇒ Text

Returns a new instance of Text.

Parameters:

  • text (String)

    the text content



55
56
57
58
# File 'lib/ask/content.rb', line 55

def initialize(text)
  @text = text
  freeze
end

Instance Attribute Details

#textString (readonly)

Returns the text content.

Returns:

  • (String)

    the text content



52
53
54
# File 'lib/ask/content.rb', line 52

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



60
61
62
# File 'lib/ask/content.rb', line 60

def ==(other)
  other.is_a?(Text) && @text == other.text
end

#hashObject



65
66
67
# File 'lib/ask/content.rb', line 65

def hash
  @text.hash
end

#to_hObject



69
70
71
# File 'lib/ask/content.rb', line 69

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