Class: Metanorma::Mirror::Model::Text
- Inherits:
-
Object
- Object
- Metanorma::Mirror::Model::Text
- Defined in:
- lib/metanorma/mirror/model/text.rb
Instance Attribute Summary collapse
-
#marks ⇒ Object
readonly
Returns the value of attribute marks.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #accept_rewriter(rewriter) ⇒ Object
-
#initialize(text:, marks: []) ⇒ Text
constructor
A new instance of Text.
- #text_content ⇒ Object
- #to_h ⇒ Object
- #type ⇒ Object
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
#marks ⇒ Object (readonly)
Returns the value of attribute marks.
7 8 9 |
# File 'lib/metanorma/mirror/model/text.rb', line 7 def marks @marks end |
#text ⇒ Object (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_content ⇒ Object
24 25 26 |
# File 'lib/metanorma/mirror/model/text.rb', line 24 def text_content @text end |
#to_h ⇒ Object
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 |
#type ⇒ Object
14 15 16 |
# File 'lib/metanorma/mirror/model/text.rb', line 14 def type "text" end |