Class: Lutaml::JsonLd::TermDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/jsonld/term_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, id: nil, type: nil, container: nil, language: nil, reverse: false) ⇒ TermDefinition

Returns a new instance of TermDefinition.



8
9
10
11
12
13
14
15
16
# File 'lib/lutaml/jsonld/term_definition.rb', line 8

def initialize(name:, id: nil, type: nil, container: nil, language: nil,
reverse: false)
  @name = name
  @id = id
  @type = type
  @container = container
  @language = language
  @reverse = reverse
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



6
7
8
# File 'lib/lutaml/jsonld/term_definition.rb', line 6

def container
  @container
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/lutaml/jsonld/term_definition.rb', line 6

def id
  @id
end

#languageObject (readonly)

Returns the value of attribute language.



6
7
8
# File 'lib/lutaml/jsonld/term_definition.rb', line 6

def language
  @language
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/lutaml/jsonld/term_definition.rb', line 6

def name
  @name
end

#reverseObject (readonly)

Returns the value of attribute reverse.



6
7
8
# File 'lib/lutaml/jsonld/term_definition.rb', line 6

def reverse
  @reverse
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/lutaml/jsonld/term_definition.rb', line 6

def type
  @type
end

Instance Method Details

#to_context_hashObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/lutaml/jsonld/term_definition.rb', line 18

def to_context_hash
  if simple_mapping?
    { @name => @id }
  else
    defn = {}
    defn["@id"] = @id if @id
    defn["@type"] = @type if @type
    defn["@container"] = "@#{@container}" if @container
    defn["@language"] = @language if @language
    defn["@reverse"] = @reverse if @reverse
    { @name => defn }
  end
end