Class: Lutaml::Rdf::MemberRule

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/rdf/member_rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr_name, predicate_name: nil, namespace: nil) ⇒ MemberRule

Returns a new instance of MemberRule.



8
9
10
11
12
13
14
15
16
17
# File 'lib/lutaml/rdf/member_rule.rb', line 8

def initialize(attr_name, predicate_name: nil, namespace: nil)
  if predicate_name && !namespace
    raise ArgumentError,
          "namespace is required when predicate_name is provided"
  end

  @attr_name = attr_name.to_sym
  @predicate_name = predicate_name
  @namespace = namespace
end

Instance Attribute Details

#attr_nameObject (readonly)

Returns the value of attribute attr_name.



6
7
8
# File 'lib/lutaml/rdf/member_rule.rb', line 6

def attr_name
  @attr_name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



6
7
8
# File 'lib/lutaml/rdf/member_rule.rb', line 6

def namespace
  @namespace
end

#predicate_nameObject (readonly)

Returns the value of attribute predicate_name.



6
7
8
# File 'lib/lutaml/rdf/member_rule.rb', line 6

def predicate_name
  @predicate_name
end

Instance Method Details

#linked?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/lutaml/rdf/member_rule.rb', line 19

def linked?
  !!@predicate_name
end

#linked_predicate_uriObject



23
24
25
26
27
# File 'lib/lutaml/rdf/member_rule.rb', line 23

def linked_predicate_uri
  return nil unless linked?

  @namespace[@predicate_name]
end