Class: Lutaml::Rdf::MemberRule

Inherits:
Object
  • Object
show all
Defined in:
lib/glossarist/rdf/ext/member_rule_ext.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr_name, inline: true, link: nil) ⇒ MemberRule

Returns a new instance of MemberRule.



15
16
17
18
19
# File 'lib/glossarist/rdf/ext/member_rule_ext.rb', line 15

def initialize(attr_name, inline: true, link: nil)
  @attr_name = attr_name.to_sym
  @inline = inline
  @link = link
end

Instance Attribute Details

#attr_nameObject (readonly)

Returns the value of attribute attr_name.



13
14
15
# File 'lib/glossarist/rdf/ext/member_rule_ext.rb', line 13

def attr_name
  @attr_name
end

#inlineObject (readonly)

Returns the value of attribute inline.



13
14
15
# File 'lib/glossarist/rdf/ext/member_rule_ext.rb', line 13

def inline
  @inline
end

Returns the value of attribute link.



13
14
15
# File 'lib/glossarist/rdf/ext/member_rule_ext.rb', line 13

def link
  @link
end

Instance Method Details



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/glossarist/rdf/ext/member_rule_ext.rb', line 21

def link_predicate_for(member, mapping)
  return nil unless @link

  case @link
  when String
    mapping.namespace_set.resolve_compact_iri(@link)
  when Proc
    uri = @link.call(member)
    uri.include?(":") ? mapping.namespace_set.resolve_compact_iri(uri) : uri
  end
end