Class: RicherText::Nodes::Mention
Constant Summary
RicherText::Node::STYLES
Instance Attribute Summary
#attrs, #children, #json, #type
Instance Method Summary
collapse
build, #style
Constructor Details
#initialize(json) ⇒ Mention
Returns a new instance of Mention.
4
5
6
7
|
# File 'lib/richer_text/nodes/mention.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
9
10
11
|
# File 'lib/richer_text/nodes/mention.rb', line 9
def accept(visitor)
visitor.visit_mention(self, @marks)
end
|
#avatar_url ⇒ Object
25
26
27
|
# File 'lib/richer_text/nodes/mention.rb', line 25
def avatar_url
@user.respond_to?(:avatar_url) ? @user.avatar_url : @attrs["avatarUrl"]
end
|
#id ⇒ Object
17
18
19
|
# File 'lib/richer_text/nodes/mention.rb', line 17
def id
@attrs["id"]
end
|
#name ⇒ Object
21
22
23
|
# File 'lib/richer_text/nodes/mention.rb', line 21
def name
@user.respond_to?(:name) ? @user.name : @attrs["label"]
end
|
#user ⇒ Object
13
14
15
|
# File 'lib/richer_text/nodes/mention.rb', line 13
def user
@user ||= GlobalID::Locator.locate(@attrs["id"])
end
|