class Line::Message::Builder::Flex::Span
Represents a span component in a LINE Flex Message.
Span components are used within a Text component to apply different styling to specific portions of text. They offer various styling options, including size, weight, color, and decoration. Unlike Text components, spans cannot have actions attached to them.
Example
Line::Message::Builder.with do flex alt_text: "Span Example" do bubble do body do text do span "Hello, ", color: "#FF0000" span "Flex ", weight: :bold span "World!", size: :xl, decoration: :underline end end end end end
See also:
-
Size::Sharedfor common size keywords (e.g.,:xl,:sm)
Attributes
The actual text content to be displayed. This is a required attribute.
Public Class Methods
Source
# File lib/line/message/builder/flex/span.rb, line 99 def initialize(text_content, context: nil, **options, &) @text = text_content # The text content is mandatory. super(context: context, **options, &) # Sets options and evals block end
Initializes a new Flex Message Span component.
- text_content
-
The text to display. This is required
- context
-
An optional context for the builder
- options
-
A hash of options to set instance variables (e.g.,
:color,:weight,:decoration, and options from included modules) - block
-
An optional block, typically not used for spans
Example
span "Hello", color: "#FF0000", weight: :bold
Calls superclass method
Line::Message::Builder::Base::new
Public Instance Methods
Source
# File lib/line/message/builder/flex/span.rb, line 112 def bold! weight(:bold) end
Source
# File lib/line/message/builder/flex/span.rb, line 134 def line_through! decoration(:"line-through") end
Source
# File lib/line/message/builder/flex/span.rb, line 123 def underline! decoration(:underline) end