Class: RicherText::Nodes::Text

Inherits:
RicherText::Node show all
Defined in:
lib/richer_text/nodes/text.rb

Constant Summary

Constants inherited from RicherText::Node

RicherText::Node::STYLES

Instance Attribute Summary

Attributes inherited from RicherText::Node

#attrs, #children, #json, #type

Instance Method Summary collapse

Methods inherited from RicherText::Node

build, #style

Constructor Details

#initialize(json) ⇒ Text

Returns a new instance of Text.



4
5
6
7
# File 'lib/richer_text/nodes/text.rb', line 4

def initialize(json)
  @marks = json.fetch("marks", []).map { |mark| RicherText::Mark.new(mark) }
  super(json)
end

Instance Method Details

#accept(visitor) ⇒ Object



13
14
15
# File 'lib/richer_text/nodes/text.rb', line 13

def accept(visitor)
  visitor.visit_text(self, @marks)
end

#textObject



9
10
11
# File 'lib/richer_text/nodes/text.rb', line 9

def text
  json["text"]
end