Class: Prosereflect::HorizontalRule
- Inherits:
-
Node
- Object
- Lutaml::Model::Serializable
- Node
- Prosereflect::HorizontalRule
show all
- Defined in:
- lib/prosereflect/horizontal_rule.rb
Overview
HorizontalRule class represents a horizontal rule in ProseMirror.
Constant Summary
collapse
- PM_TYPE =
"horizontal_rule"
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Node
#copy, #cut, #descendants, #eq?, #find_all, #find_children, #find_first, #marks, #marks=, #node, #node_size, #nodes_between, #parse_content, #process_attrs_data, #raw_marks, #resolve, #text?, #text_content, #to_yaml
Constructor Details
#initialize(attributes = {}) ⇒ HorizontalRule
Returns a new instance of HorizontalRule.
22
23
24
25
|
# File 'lib/prosereflect/horizontal_rule.rb', line 22
def initialize(attributes = {})
attributes[:content] = []
super
end
|
Class Method Details
.create(attrs = nil) ⇒ Object
27
28
29
|
# File 'lib/prosereflect/horizontal_rule.rb', line 27
def self.create(attrs = nil)
new(attrs: attrs)
end
|
Instance Method Details
#add_child ⇒ Object
71
72
73
|
# File 'lib/prosereflect/horizontal_rule.rb', line 71
def add_child(*)
raise NotImplementedError, "Horizontal rule nodes cannot have children"
end
|
#content ⇒ Object
75
76
77
|
# File 'lib/prosereflect/horizontal_rule.rb', line 75
def content
[]
end
|
#style ⇒ Object
37
38
39
|
# File 'lib/prosereflect/horizontal_rule.rb', line 37
def style
@style || attrs&.[]("style")
end
|
#style=(value) ⇒ Object
31
32
33
34
35
|
# File 'lib/prosereflect/horizontal_rule.rb', line 31
def style=(value)
@style = value
self.attrs ||= {}
attrs["style"] = value
end
|
#thickness ⇒ Object
57
58
59
|
# File 'lib/prosereflect/horizontal_rule.rb', line 57
def thickness
@thickness || attrs&.[]("thickness")
end
|
#thickness=(value) ⇒ Object
51
52
53
54
55
|
# File 'lib/prosereflect/horizontal_rule.rb', line 51
def thickness=(value)
@thickness = value
self.attrs ||= {}
attrs["thickness"] = value
end
|
#to_h ⇒ Object
Override content-related methods since horizontal rules don’t have content
62
63
64
65
66
67
68
69
|
# File 'lib/prosereflect/horizontal_rule.rb', line 62
def to_h
hash = super
if hash["attrs"]
%w[style width thickness].each { |k| hash["attrs"].delete(k) if hash["attrs"][k].nil? }
hash.delete("attrs") if hash["attrs"].empty?
end
hash
end
|
#width ⇒ Object
47
48
49
|
# File 'lib/prosereflect/horizontal_rule.rb', line 47
def width
@width || attrs&.[]("width")
end
|
#width=(value) ⇒ Object
41
42
43
44
45
|
# File 'lib/prosereflect/horizontal_rule.rb', line 41
def width=(value)
@width = value
self.attrs ||= {}
attrs["width"] = value
end
|