Class: JSI::Schema::Vocabulary
- Inherits:
-
Object
- Object
- JSI::Schema::Vocabulary
- Defined in:
- lib/jsi/schema/vocabulary.rb
Instance Attribute Summary collapse
- #elements ⇒ Set<Schema::Element> readonly
- #id ⇒ URI? readonly
Instance Method Summary collapse
-
#initialize(id: nil, elements:) ⇒ Vocabulary
constructor
A new instance of Vocabulary.
- #pretty_print(q) ⇒ Object
Constructor Details
#initialize(id: nil, elements:) ⇒ Vocabulary
Returns a new instance of Vocabulary.
10 11 12 13 14 15 16 |
# File 'lib/jsi/schema/vocabulary.rb', line 10 def initialize(id: nil, elements: ) @id = Util.uri(id, nnil: false, yabs: true, ynorm: true) raise(TypeError, "elements: #{elements}") unless elements.all? { |e| e.is_a?(Schema::Element) } @elements = Set.new(elements).freeze freeze end |
Instance Attribute Details
#elements ⇒ Set<Schema::Element> (readonly)
22 23 24 |
# File 'lib/jsi/schema/vocabulary.rb', line 22 def elements @elements end |
#id ⇒ URI? (readonly)
19 20 21 |
# File 'lib/jsi/schema/vocabulary.rb', line 19 def id @id end |
Instance Method Details
#pretty_print(q) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/jsi/schema/vocabulary.rb', line 25 def pretty_print(q) if id jsi_pp_object_group(q, [self.class.name, -"id: <#{id}>"]) else jsi_pp_object_group(q) do q.seplist(elements) { |e| q.pp(e) } end end end |