Class: Markbridge::AST::Url

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

Overview

Represents a hyperlink/URL element.

Examples:

URL with explicit href

url = AST::Url.new(href: "https://example.com")
url << AST::Text.new("Click here")

URL with text as href

url = AST::Url.new(href: "https://example.com")
url << AST::Text.new("https://example.com")

Instance Attribute Summary collapse

Attributes inherited from Element

#children

Instance Method Summary collapse

Methods inherited from Element

#<<

Constructor Details

#initialize(href: nil) ⇒ Url

Create a new URL element.

Parameters:

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

    the URL/href for this link



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

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

Instance Attribute Details

#hrefString? (readonly)

Returns the URL/href for this link.

Returns:

  • (String, nil)

    the URL/href for this link



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

def href
  @href
end