Class: Markbridge::AST::Spoiler

Inherits:
Element show all
Defined in:
lib/markbridge/ast/spoiler.rb

Overview

Represents a spoiler element (hidden content).

Examples:

Basic spoiler

spoiler = AST::Spoiler.new
spoiler << AST::Text.new("Hidden content")

Spoiler with title

spoiler = AST::Spoiler.new(title: "Click to reveal")
spoiler << AST::Text.new("Hidden content")

Instance Attribute Summary collapse

Attributes inherited from Element

#children

Instance Method Summary collapse

Methods inherited from Element

#<<

Constructor Details

#initialize(title: nil) ⇒ Spoiler

Create a new Spoiler element.

Parameters:

  • title (String, nil) (defaults to: nil)

    optional title for the spoiler



21
22
23
24
# File 'lib/markbridge/ast/spoiler.rb', line 21

def initialize(title: nil)
  super()
  @title = title
end

Instance Attribute Details

#titleString? (readonly)

Returns the spoiler title/label.

Returns:

  • (String, nil)

    the spoiler title/label



16
17
18
# File 'lib/markbridge/ast/spoiler.rb', line 16

def title
  @title
end