Class: Chemicalml::Schema::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/chemicalml/schema/definition.rb

Overview

Value object describing one CML schema version. Immutable.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version:, xsd_path:, xml_namespace:, ruby_namespace:) ⇒ Definition

Returns a new instance of Definition.



9
10
11
12
13
14
15
# File 'lib/chemicalml/schema/definition.rb', line 9

def initialize(version:, xsd_path:, xml_namespace:, ruby_namespace:)
  @version = version
  @xsd_path = xsd_path
  @xml_namespace = xml_namespace
  @ruby_namespace = ruby_namespace
  freeze
end

Instance Attribute Details

#ruby_namespaceObject (readonly)

Returns the value of attribute ruby_namespace.



7
8
9
# File 'lib/chemicalml/schema/definition.rb', line 7

def ruby_namespace
  @ruby_namespace
end

#versionObject (readonly)

Returns the value of attribute version.



7
8
9
# File 'lib/chemicalml/schema/definition.rb', line 7

def version
  @version
end

#xml_namespaceObject (readonly)

Returns the value of attribute xml_namespace.



7
8
9
# File 'lib/chemicalml/schema/definition.rb', line 7

def xml_namespace
  @xml_namespace
end

#xsd_pathObject (readonly)

Returns the value of attribute xsd_path.



7
8
9
# File 'lib/chemicalml/schema/definition.rb', line 7

def xsd_path
  @xsd_path
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


25
26
27
# File 'lib/chemicalml/schema/definition.rb', line 25

def eql?(other)
  other.is_a?(Definition) && version == other.version
end

#hashObject



30
31
32
# File 'lib/chemicalml/schema/definition.rb', line 30

def hash
  version.hash
end

#wire_namespace_constantObject



21
22
23
# File 'lib/chemicalml/schema/definition.rb', line 21

def wire_namespace_constant
  ruby_namespace.split("::").reduce(Object) { |ns, name| ns.const_get(name) }
end

#xsd_full_pathObject



17
18
19
# File 'lib/chemicalml/schema/definition.rb', line 17

def xsd_full_path
  File.expand_path(xsd_path, project_root)
end