class Line::Message::Builder::Flex::Builder
The Builder class is the main entry point for constructing a complete LINE Flex Message. A Flex Message is a highly customizable message type that can contain one main content element, which is either a single Bubble or a Carousel of bubbles.
This builder requires alt_text (alternative text) for accessibility and for display on devices or LINE versions that cannot render Flex Messages. It can also have a quickReply attached to it.
Example: Creating a Flex Message with a single bubble
Line::Message::Builder.with do flex alt_text: "My Product" do flex_builder.bubble size: :giga do hero_image "https://example.com/product.jpg" body do text "Product Name", weight: :bold, size: :xl end end quick_reply do button action: :message, label: "Learn More", text: "Tell me more" end end end
See also:
Public Class Methods
Source
# File lib/line/message/builder/flex/builder.rb, line 61 def initialize(context: nil, **options, &) @contents = nil # Will hold either a Bubble or Carousel instance super # Calls Base#initialize, sets options (like @alt_text), and evals block end
Initializes a new Flex Message Builder. The provided block is instance-evalβd, allowing DSL methods like bubble or carousel to define the main content.
- context
-
An optional context for the builder.
- option
-
A hash of options to set instance variables (e.g.,
:alt_text). - block
-
A block to define the content (bubble or carousel) of this
FlexMessage.
Line::Message::Builder::Base::new
Public Instance Methods
Source
# File lib/line/message/builder/flex/builder.rb, line 74 def bubble(**options, &) @contents = Line::Message::Builder::Flex::Bubble.new(context: context, **options, &) end
Source
# File lib/line/message/builder/flex/builder.rb, line 85 def carousel(**options, &) @contents = Line::Message::Builder::Flex::Carousel.new(context: context, **options, &) end