Class: Metanorma::Mirror::Model::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/metanorma/mirror/model/text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, marks: []) ⇒ Text

Returns a new instance of Text.



9
10
11
12
# File 'lib/metanorma/mirror/model/text.rb', line 9

def initialize(text:, marks: [])
  @text = text.to_s
  @marks = Array(marks)
end

Instance Attribute Details

#marksObject (readonly)

Returns the value of attribute marks.



7
8
9
# File 'lib/metanorma/mirror/model/text.rb', line 7

def marks
  @marks
end

#textObject (readonly)

Returns the value of attribute text.



7
8
9
# File 'lib/metanorma/mirror/model/text.rb', line 7

def text
  @text
end

Instance Method Details

#accept_rewriter(rewriter) ⇒ Object



28
29
30
# File 'lib/metanorma/mirror/model/text.rb', line 28

def accept_rewriter(rewriter)
  rewriter.rewrite_text(self)
end

#text_contentObject



24
25
26
# File 'lib/metanorma/mirror/model/text.rb', line 24

def text_content
  @text
end

#to_hObject



18
19
20
21
22
# File 'lib/metanorma/mirror/model/text.rb', line 18

def to_h
  h = { "type" => "text", "text" => @text }
  h["marks"] = @marks.map(&:to_h) unless @marks.empty?
  h
end

#typeObject



14
15
16
# File 'lib/metanorma/mirror/model/text.rb', line 14

def type
  "text"
end