Class: Lutaml::Model::Schema::XmlCompiler::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/model/schema/xml_compiler/element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, ref: nil) ⇒ Element

Returns a new instance of Element.



17
18
19
20
# File 'lib/lutaml/model/schema/xml_compiler/element.rb', line 17

def initialize(name: nil, ref: nil)
  @name = name
  @ref = ref
end

Instance Attribute Details

#defaultObject

Returns the value of attribute default.



8
9
10
# File 'lib/lutaml/model/schema/xml_compiler/element.rb', line 8

def default
  @default
end

#fixedObject

Returns the value of attribute fixed.



8
9
10
# File 'lib/lutaml/model/schema/xml_compiler/element.rb', line 8

def fixed
  @fixed
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/lutaml/model/schema/xml_compiler/element.rb', line 8

def id
  @id
end

#max_occursObject

Returns the value of attribute max_occurs.



8
9
10
# File 'lib/lutaml/model/schema/xml_compiler/element.rb', line 8

def max_occurs
  @max_occurs
end

#min_occursObject

Returns the value of attribute min_occurs.



8
9
10
# File 'lib/lutaml/model/schema/xml_compiler/element.rb', line 8

def min_occurs
  @min_occurs
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/lutaml/model/schema/xml_compiler/element.rb', line 8

def name
  @name
end

#refObject

Returns the value of attribute ref.



8
9
10
# File 'lib/lutaml/model/schema/xml_compiler/element.rb', line 8

def ref
  @ref
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/lutaml/model/schema/xml_compiler/element.rb', line 8

def type
  @type
end

Instance Method Details

#required_filesObject



36
37
38
39
40
41
42
43
44
# File 'lib/lutaml/model/schema/xml_compiler/element.rb', line 36

def required_files
  return if skippable?

  element_type = resolved_type(change_case: false)
  return "require \"bigdecimal\"" if element_type == "decimal"
  return if SimpleType.skippable?(element_type)

  "require_relative \"#{Utils.snake_case(element_type)}\""
end

#to_attributes(indent) ⇒ Object



22
23
24
25
26
27
# File 'lib/lutaml/model/schema/xml_compiler/element.rb', line 22

def to_attributes(indent)
  return if skippable?
  return unless resolved_type

  "#{indent}attribute :#{resolved_name}, :#{resolved_type}#{attribute_options}\n"
end

#to_xml_mapping(indent) ⇒ Object



29
30
31
32
33
34
# File 'lib/lutaml/model/schema/xml_compiler/element.rb', line 29

def to_xml_mapping(indent)
  return if skippable?
  return unless resolved_type

  "#{indent}map_element :#{resolved_name(change_case: false)}, to: :#{resolved_name}#{render_default_option}\n"
end