Class: Eddy::Models::Element::ID

Inherits:
Base
  • Object
show all
Defined in:
lib/eddy/models/element/id.rb

Overview

Identifier. Works with a code list specified by the dictionary.

Instance Attribute Summary

Attributes inherited from Base

#description, #id, #max, #min, #name, #ref, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#doc_comment, #req, #req=

Constructor Details

#initialize(min:, max:, req: nil, ref: nil, val: nil) ⇒ void

Parameters:

  • min (Integer)
  • max (Integer)
  • req (String) (defaults to: nil)

    (nil)

  • ref (String) (defaults to: nil)

    (nil)

  • val (String) (defaults to: nil)

    (nil)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/eddy/models/element/id.rb', line 13

def initialize(
  min:,
  max:,
  req: nil,
  ref: nil,
  val: nil
)
  @type = "ID"
  @min = min
  @max = max
  self.req = req
  self.ref = ref
  self.value = val
end

Class Method Details

.process_value(val) ⇒ String

Parameters:

  • val (String)

    Original value.

Returns:

  • (String)


56
57
58
# File 'lib/eddy/models/element/id.rb', line 56

def self.process_value(val)
  return val
end

Instance Method Details

#code_listArray<String>

Returns:

  • (Array<String>)

Raises:

  • (NotImplementedError)


61
62
63
# File 'lib/eddy/models/element/id.rb', line 61

def code_list()
  raise NotImplementedError, "Each ID element must define its own code_list"
end

#process_valueString

Returns:

  • (String)


50
51
52
# File 'lib/eddy/models/element/id.rb', line 50

def process_value()
  return self.class.process_value(@val)
end

#valueString

Returns:

  • (String)

Raises:



45
46
47
# File 'lib/eddy/models/element/id.rb', line 45

def value()
  return super()
end

#value=(arg) ⇒ Object

return [void]

Parameters:

  • arg (String)

Raises:



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/eddy/models/element/id.rb', line 30

def value=(arg)
  if arg == :skip
    @val = :skip
    return
  end
  if arg.nil?()
    @val = arg
    return
  end
  raise Eddy::Errors::ElementValidationError.new("Value not present in code list: #{arg}", element: self) unless self.code_list().include?(arg)
  @val = arg
end