Class: LUSI::API::Core::BasicCode

Inherits:
Object
  • Object
show all
Defined in:
lib/lusi_api/core/code.rb

Overview

Represents a LUSI code definition (identity code and text description)

Direct Known Subclasses

Code

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml = nil, lookup = nil, identity: nil, description: nil) ⇒ void

Initialises a new Code instance

Parameters:

  • xml (Nokogiri::XML::Document, Nokogiri::XML::Node) (defaults to: nil)

    the XML root of the code from the LUSI API

  • lookup (LUSI::API::Core::Lookup::LookupService, nil) (defaults to: nil)

    the lookup service for object resolution

  • identity (any, nil) (defaults to: nil)

    the default identity code

  • description (String, nil) (defaults to: nil)

    the default text description



26
27
28
29
# File 'lib/lusi_api/core/code.rb', line 26

def initialize(xml = nil, lookup = nil, identity: nil, description: nil)
  @description = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Description', description)
  @identity = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Identity', identity)
end

Instance Attribute Details

#descriptionany?

Returns the text description.

Returns:

  • (any, nil)

    the text description



14
15
16
# File 'lib/lusi_api/core/code.rb', line 14

def description
  @description
end

#identityany?

Returns the identity code.

Returns:

  • (any, nil)

    the identity code



18
19
20
# File 'lib/lusi_api/core/code.rb', line 18

def identity
  @identity
end

Class Method Details

.get_instance(*args, **kwargs) ⇒ Object

Default get_instance implementation

  • Instances cannot be retrieved through the LUSI API

Raises:

  • (NotImplementedError)


39
40
41
# File 'lib/lusi_api/core/code.rb', line 39

def self.get_instance(*args, **kwargs)
  raise NotImplementedError
end

Instance Method Details

#to_sString?

Returns a string representation of the code

Returns:

  • (String, nil)

    the string representation (text description)



33
34
35
# File 'lib/lusi_api/core/code.rb', line 33

def to_s
  @description
end