Class: Prosereflect::Schema::SchemaSpec
- Inherits:
-
Object
- Object
- Prosereflect::Schema::SchemaSpec
- Defined in:
- lib/prosereflect/schema/spec.rb
Overview
Represents a complete schema specification
Instance Attribute Summary collapse
-
#marks ⇒ Object
readonly
Returns the value of attribute marks.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#top_node ⇒ Object
readonly
Returns the value of attribute top_node.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(nodes: {}, marks: {}, top_node: nil) ⇒ SchemaSpec
constructor
A new instance of SchemaSpec.
Constructor Details
#initialize(nodes: {}, marks: {}, top_node: nil) ⇒ SchemaSpec
Returns a new instance of SchemaSpec.
74 75 76 77 78 |
# File 'lib/prosereflect/schema/spec.rb', line 74 def initialize(nodes: {}, marks: {}, top_node: nil) @nodes = nodes @marks = marks @top_node = top_node || "doc" end |
Instance Attribute Details
#marks ⇒ Object (readonly)
Returns the value of attribute marks.
72 73 74 |
# File 'lib/prosereflect/schema/spec.rb', line 72 def marks @marks end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
72 73 74 |
# File 'lib/prosereflect/schema/spec.rb', line 72 def nodes @nodes end |
#top_node ⇒ Object (readonly)
Returns the value of attribute top_node.
72 73 74 |
# File 'lib/prosereflect/schema/spec.rb', line 72 def top_node @top_node end |
Class Method Details
.from_hashes(nodes_spec:, marks_spec: {}, top_node: nil) ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/prosereflect/schema/spec.rb', line 80 def self.from_hashes(nodes_spec:, marks_spec: {}, top_node: nil) nodes = nodes_spec.each_with_object({}) do |(name, spec), hash| hash[name] = NodeSpec.from_hash(name, spec) end marks = marks_spec.each_with_object({}) do |(name, spec), hash| hash[name] = MarkSpec.from_hash(name, spec) end new(nodes: nodes, marks: marks, top_node: top_node) end |