Class: Lutaml::Model::Schema::RngCompiler::DefineClassifier

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/model/schema/rng_compiler/define_classifier.rb

Overview

Detects the shape of a body and builds the corresponding Definitions::* spec for it.

<data type="X"><param ...>...</param></data>      -> RestrictedType
<choice><value>a</value><value>b</value></choice> -> RestrictedType (enum)
<choice><data type="A"/><data type="B"/></choice> -> UnionType

Returns nil when the define is structural (contains elements or attributes) — caller falls back to building a Definitions::Model.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(define, class_name) ⇒ DefineClassifier

Returns a new instance of DefineClassifier.



21
22
23
24
# File 'lib/lutaml/model/schema/rng_compiler/define_classifier.rb', line 21

def initialize(define, class_name)
  @define = define
  @class_name = class_name
end

Class Method Details

.build(define, class_name) ⇒ Object



17
18
19
# File 'lib/lutaml/model/schema/rng_compiler/define_classifier.rb', line 17

def self.build(define, class_name)
  new(define, class_name).build
end

Instance Method Details

#buildObject



26
27
28
29
30
# File 'lib/lutaml/model/schema/rng_compiler/define_classifier.rb', line 26

def build
  return nil if structural_define?

  union_type || data_restricted_type || enum_restricted_type
end