Class: Prosereflect::Schema::NodeSpec
- Inherits:
-
Object
- Object
- Prosereflect::Schema::NodeSpec
- Defined in:
- lib/prosereflect/schema/spec.rb
Overview
Represents a node specification from a schema
Instance Attribute Summary collapse
-
#atom ⇒ Object
readonly
Returns the value of attribute atom.
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#inline ⇒ Object
readonly
Returns the value of attribute inline.
-
#marks ⇒ Object
readonly
Returns the value of attribute marks.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, attrs: {}, content: nil, groups: [], inline: false, atom: false, marks: nil) ⇒ NodeSpec
constructor
A new instance of NodeSpec.
Constructor Details
#initialize(name:, attrs: {}, content: nil, groups: [], inline: false, atom: false, marks: nil) ⇒ NodeSpec
Returns a new instance of NodeSpec.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/prosereflect/schema/spec.rb', line 9 def initialize(name:, attrs: {}, content: nil, groups: [], inline: false, atom: false, marks: nil) @name = name @attrs = attrs @content = content @groups = groups @inline = inline @atom = atom @marks = marks end |
Instance Attribute Details
#atom ⇒ Object (readonly)
Returns the value of attribute atom.
7 8 9 |
# File 'lib/prosereflect/schema/spec.rb', line 7 def atom @atom end |
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
7 8 9 |
# File 'lib/prosereflect/schema/spec.rb', line 7 def attrs @attrs end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/prosereflect/schema/spec.rb', line 7 def content @content end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
7 8 9 |
# File 'lib/prosereflect/schema/spec.rb', line 7 def groups @groups end |
#inline ⇒ Object (readonly)
Returns the value of attribute inline.
7 8 9 |
# File 'lib/prosereflect/schema/spec.rb', line 7 def inline @inline end |
#marks ⇒ Object (readonly)
Returns the value of attribute marks.
7 8 9 |
# File 'lib/prosereflect/schema/spec.rb', line 7 def marks @marks end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/prosereflect/schema/spec.rb', line 7 def name @name end |
Class Method Details
.from_hash(name, spec) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/prosereflect/schema/spec.rb', line 20 def self.from_hash(name, spec) new( name: name, attrs: spec[:attrs] || spec["attrs"] || {}, content: spec[:content] || spec["content"], groups: parse_groups(spec), inline: spec[:inline] || spec["inline"] || false, atom: spec[:atom] || spec["atom"] || false, marks: spec[:marks] || spec["marks"], ) end |
.parse_groups(spec) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/prosereflect/schema/spec.rb', line 32 def self.parse_groups(spec) group_str = spec[:group] || spec["group"] return [] unless group_str group_str.is_a?(Array) ? group_str : group_str.to_s.split end |