Class: Line::Message::Builder::Text
- Defined in:
- lib/line/message/builder/text.rb
Overview
The Text class provides a builder for creating simple text messages in the LINE Messaging API. Text messages are the most basic message type, consisting of plain text content with optional quick reply buttons and quote tokens for replying to specific messages.
Text messages support:
- Plain text content (up to 5,000 characters)
- Quick reply buttons for user interaction
- Quote tokens to reply to specific messages in a conversation
Example: Basic text message
Line::Message::Builder.with do
text "Hello, world!"
end
Example: Text with quick reply
Line::Message::Builder.with do
text "Choose an option:" do
quick_reply do
action: :message, label: "Yes", text: "I agree"
action: :message, label: "No", text: "I disagree"
end
end
end
Example: Text with quote token
Line::Message::Builder.with do
text "This is a reply" do
quote_token "sample_quote_token_value"
end
end
The Text builder inherits from Base and can be used within the
Line::Message::Builder.with block using the text method.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(text, context: nil, **options, &block) ⇒ Text
constructor
Creates a new text message builder.
Methods inherited from Base
inherited, #method_missing, #quick_reply, #respond_to_missing?, #to_h
Constructor Details
#initialize(text, context: nil, **options, &block) ⇒ Text
Creates a new text message builder.
[text]
The text content of the message (up to 5,000 characters)
[context]
An optional context object for method delegation (default: nil)
[option]
Additional options to configure the text message
[block]
Optional block for configuring quick replies or quote token
Example
text = Text.new("Hello!", context: view_context) do
quick_reply do
action: :message, label: "Hi", text: "Hi back!"
end
end
77 78 79 80 81 |
# File 'lib/line/message/builder/text.rb', line 77 def initialize(text, context: nil, **, &block) @text = text super(context: context, **, &block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Line::Message::Builder::Base