Class: Markbridge::AST::Mention

Inherits:
Node
  • Object
show all
Defined in:
lib/markbridge/ast/mention.rb

Overview

Represents a user or group mention (@username or @groupname).

Examples:

User mention

mention = AST::Mention.new(name: "gerhard", type: :user)

Group mention

mention = AST::Mention.new(name: "Testers", type: :group)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type: :user) ⇒ Mention

Create a new Mention node.

Parameters:

  • name (String)

    the username or group name (without @)

  • type (Symbol) (defaults to: :user)

    the type of mention (:user or :group), defaults to :user



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

def initialize(name:, type: :user)
  @name = name
  @type = type
end

Instance Attribute Details

#nameString (readonly)

Returns the username or group name (without @).

Returns:

  • (String)

    the username or group name (without @)



14
15
16
# File 'lib/markbridge/ast/mention.rb', line 14

def name
  @name
end

#typeSymbol (readonly)

Returns the type of mention (:user or :group).

Returns:

  • (Symbol)

    the type of mention (:user or :group)



17
18
19
# File 'lib/markbridge/ast/mention.rb', line 17

def type
  @type
end