Class: Lutaml::Rdf::MappingRule

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(predicate_name, namespace:, to:, lang_tagged: false, uri_reference: false) ⇒ MappingRule

Returns a new instance of MappingRule.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/lutaml/rdf/mapping_rule.rb', line 8

def initialize(predicate_name, namespace:, to:, lang_tagged: false,
               uri_reference: false)
  validate!(predicate_name, namespace, to)
  if lang_tagged && uri_reference
    raise ArgumentError,
          "lang_tagged and uri_reference are mutually exclusive"
  end

  @predicate_name = predicate_name.to_s.freeze
  @namespace = namespace
  @to = to
  @lang_tagged = lang_tagged
  @uri_reference = uri_reference
end

Instance Attribute Details

#lang_taggedObject (readonly)

Returns the value of attribute lang_tagged.



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

def lang_tagged
  @lang_tagged
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



6
7
8
# File 'lib/lutaml/rdf/mapping_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/mapping_rule.rb', line 6

def predicate_name
  @predicate_name
end

#toObject (readonly)

Returns the value of attribute to.



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

def to
  @to
end

#uri_referenceObject (readonly)

Returns the value of attribute uri_reference.



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

def uri_reference
  @uri_reference
end

Instance Method Details

#kindObject



23
24
25
26
27
28
29
30
31
# File 'lib/lutaml/rdf/mapping_rule.rb', line 23

def kind
  if uri_reference
    :uri_reference
  elsif lang_tagged
    :lang_tagged
  else
    :plain
  end
end

#prefixed_nameObject



37
38
39
# File 'lib/lutaml/rdf/mapping_rule.rb', line 37

def prefixed_name
  @namespace.prefixed(@predicate_name)
end

#uriObject



33
34
35
# File 'lib/lutaml/rdf/mapping_rule.rb', line 33

def uri
  @namespace[@predicate_name]
end