Class: Dina::ProtocolData

Inherits:
Object
  • Object
show all
Defined in:
lib/dina/components/protocol_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProtocolData

Returns a new instance of ProtocolData.



7
8
9
# File 'lib/dina/components/protocol_data.rb', line 7

def initialize
  @protocolDataElement = []
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



3
4
5
# File 'lib/dina/components/protocol_data.rb', line 3

def key
  @key
end

#protocolDataElementObject

array



5
6
7
# File 'lib/dina/components/protocol_data.rb', line 5

def protocolDataElement
  @protocolDataElement
end

#vocabularyBasedObject

boolean



4
5
6
# File 'lib/dina/components/protocol_data.rb', line 4

def vocabularyBased
  @vocabularyBased
end

Instance Method Details

#add_data_element(element:) ⇒ Object



11
12
13
14
15
16
# File 'lib/dina/components/protocol_data.rb', line 11

def add_data_element(element:)
  if !element.instance_of?(ProtocolDataElement)
    raise PropertyValueInvalid, "Data Element must be a ProtocolDataElement."
  end
  @protocolDataElement << element.to_hash
end

#to_hashObject

Produce a hash with symbolized keys



19
20
21
22
23
# File 'lib/dina/components/protocol_data.rb', line 19

def to_hash
  hash = {}
  instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
  hash.deep_symbolize_keys
end