Class: JSI::Schema::Vocabulary

Inherits:
Object
  • Object
show all
Defined in:
lib/jsi/schema/vocabulary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, elements:) ⇒ Vocabulary

Returns a new instance of Vocabulary.

Parameters:

  • id (#to_str, nil) (defaults to: nil)
  • elements (Enumerable<Schema::Element>)

Raises:

  • (TypeError)


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

#elementsSet<Schema::Element> (readonly)

Returns:



22
23
24
# File 'lib/jsi/schema/vocabulary.rb', line 22

def elements
  @elements
end

#idURI? (readonly)

Returns:

  • (URI, nil)


19
20
21
# File 'lib/jsi/schema/vocabulary.rb', line 19

def id
  @id
end

Instance Method Details

#pretty_print(q) ⇒ Object

Parameters:

  • q


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