Class: Gemtext::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/gemtext/node.rb

Overview

‘Gemtext::Node` represents a piece of a document. There are a limited number of node types. They store their content with any formatting needed to identify that content removed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content = nil) ⇒ Node

Returns a new instance of Node.



9
10
11
# File 'lib/gemtext/node.rb', line 9

def initialize(content = nil)
  @content = content
end

Instance Attribute Details

#contentObject (readonly)

The content of the node



7
8
9
# File 'lib/gemtext/node.rb', line 7

def content
  @content
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
# File 'lib/gemtext/node.rb', line 17

def ==(other)
  other.class == self.class && other.content == @content
end

#deconstruct_keys(*_keys) ⇒ Object



21
22
23
# File 'lib/gemtext/node.rb', line 21

def deconstruct_keys(*_keys)
  { content: }
end

#inspectObject



13
14
15
# File 'lib/gemtext/node.rb', line 13

def inspect
  "#{self.class}{#{content}}"
end