Class: Markbridge::AST::Quote

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

Overview

Represents a quote/blockquote element.

Examples:

Basic quote

quote = AST::Quote.new
quote << AST::Text.new("quoted text")

Quote with author attribution

quote = AST::Quote.new(author: "John")
quote << AST::Text.new("quoted text")

Quote with full Discourse context

quote = AST::Quote.new(author: "John", post: "123", topic: "456", username: "john123")
quote << AST::Text.new("quoted text")

Instance Attribute Summary collapse

Attributes inherited from Element

#children

Instance Method Summary collapse

Methods inherited from Element

#<<

Constructor Details

#initialize(author: nil, post: nil, topic: nil, username: nil) ⇒ Quote

Create a new Quote element.

Parameters:

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

    the author attribution

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

    the post ID (Discourse-specific)

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

    the topic ID (Discourse-specific)

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

    the username (Discourse-specific)



37
38
39
40
41
42
43
# File 'lib/markbridge/ast/quote.rb', line 37

def initialize(author: nil, post: nil, topic: nil, username: nil)
  super()
  @author = author
  @post = post
  @topic = topic
  @username = username
end

Instance Attribute Details

#authorString? (readonly)

Returns the author/username of the quote.

Returns:

  • (String, nil)

    the author/username of the quote



20
21
22
# File 'lib/markbridge/ast/quote.rb', line 20

def author
  @author
end

#postString? (readonly)

Returns the post ID for Discourse quotes.

Returns:

  • (String, nil)

    the post ID for Discourse quotes



23
24
25
# File 'lib/markbridge/ast/quote.rb', line 23

def post
  @post
end

#topicString? (readonly)

Returns the topic ID for Discourse quotes.

Returns:

  • (String, nil)

    the topic ID for Discourse quotes



26
27
28
# File 'lib/markbridge/ast/quote.rb', line 26

def topic
  @topic
end

#usernameString? (readonly)

Returns the username for Discourse quotes.

Returns:

  • (String, nil)

    the username for Discourse quotes



29
30
31
# File 'lib/markbridge/ast/quote.rb', line 29

def username
  @username
end