Class: Lutaml::Model::Schema::XmlCompiler::XmlNamespaceClass
- Inherits:
-
Object
- Object
- Lutaml::Model::Schema::XmlCompiler::XmlNamespaceClass
- Defined in:
- lib/lutaml/model/schema/xml_compiler/xml_namespace_class.rb
Overview
Generates XmlNamespace class definitions from XSD namespace URIs
Constant Summary collapse
- TEMPLATE =
ERB.new(<<~TEMPLATE, trim_mode: "-") # frozen_string_literal: true require "lutaml/model" <%= module_opening -%> # Namespace: <%= uri %> class <%= class_name %> < Lutaml::Xml::W3c::XmlNamespace uri <%= uri.inspect %> prefix_default <%= prefix_default.inspect %> end <%= module_closing -%> TEMPLATE
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#prefix_default ⇒ Object
Returns the value of attribute prefix_default.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #class_reference ⇒ Object
-
#initialize(uri:, prefix: nil, class_name: nil) ⇒ XmlNamespaceClass
constructor
A new instance of XmlNamespaceClass.
- #required_file ⇒ Object
- #to_class(options: {}) ⇒ Object
Constructor Details
#initialize(uri:, prefix: nil, class_name: nil) ⇒ XmlNamespaceClass
Returns a new instance of XmlNamespaceClass.
25 26 27 28 29 30 |
# File 'lib/lutaml/model/schema/xml_compiler/xml_namespace_class.rb', line 25 def initialize(uri:, prefix: nil, class_name: nil) @uri = uri @prefix_default = prefix || derive_prefix_from_uri(uri) @class_name = class_name || derive_class_name_from_uri(uri) @module_namespace = nil end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
9 10 11 |
# File 'lib/lutaml/model/schema/xml_compiler/xml_namespace_class.rb', line 9 def class_name @class_name end |
#prefix_default ⇒ Object
Returns the value of attribute prefix_default.
9 10 11 |
# File 'lib/lutaml/model/schema/xml_compiler/xml_namespace_class.rb', line 9 def prefix_default @prefix_default end |
#uri ⇒ Object
Returns the value of attribute uri.
9 10 11 |
# File 'lib/lutaml/model/schema/xml_compiler/xml_namespace_class.rb', line 9 def uri @uri end |
Instance Method Details
#class_reference ⇒ Object
42 43 44 |
# File 'lib/lutaml/model/schema/xml_compiler/xml_namespace_class.rb', line 42 def class_reference class_name end |
#required_file ⇒ Object
38 39 40 |
# File 'lib/lutaml/model/schema/xml_compiler/xml_namespace_class.rb', line 38 def required_file "require_relative \"#{Utils.snake_case(class_name)}\"" end |
#to_class(options: {}) ⇒ Object
32 33 34 35 36 |
# File 'lib/lutaml/model/schema/xml_compiler/xml_namespace_class.rb', line 32 def to_class(options: {}) @module_namespace = [:module_namespace] @modules = @module_namespace&.split("::") || [] TEMPLATE.result(binding) end |