Class: Opencdd::PropertyDataTypeElement

Inherits:
Object
  • Object
show all
Defined in:
lib/opencdd/property_data_element_type.rb

Constant Summary collapse

VALUES =
%w[NON_DEPENDENT_P_DET CONDITION_DET DEPENDENT_P_DET].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ PropertyDataTypeElement

Returns a new instance of PropertyDataTypeElement.

Raises:

  • (ArgumentError)


9
10
11
12
13
# File 'lib/opencdd/property_data_element_type.rb', line 9

def initialize(value)
  v = value.to_s.strip.upcase
  raise ArgumentError, "unknown property data element type: #{value.inspect}" unless VALUES.include?(v)
  @value = v
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/opencdd/property_data_element_type.rb', line 7

def value
  @value
end

Class Method Details

.parse(raw) ⇒ Object



37
38
39
40
41
42
# File 'lib/opencdd/property_data_element_type.rb', line 37

def self.parse(raw)
  return nil if raw.nil? || raw.to_s.strip.empty?
  s = raw.to_s.strip.upcase
  return nil unless VALUES.include?(s)
  new(s)
end

Instance Method Details

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



26
27
28
# File 'lib/opencdd/property_data_element_type.rb', line 26

def ==(other)
  other.is_a?(Opencdd::PropertyDataTypeElement) && @value == other.value
end

#condition?Boolean

Returns:

  • (Boolean)


16
# File 'lib/opencdd/property_data_element_type.rb', line 16

def condition?      = @value == "CONDITION_DET"

#conditional?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/opencdd/property_data_element_type.rb', line 19

def conditional?
  condition? || dependent?
end

#dependent?Boolean

Returns:

  • (Boolean)


17
# File 'lib/opencdd/property_data_element_type.rb', line 17

def dependent?      = @value == "DEPENDENT_P_DET"

#hashObject



31
32
33
# File 'lib/opencdd/property_data_element_type.rb', line 31

def hash
  @value.hash
end

#non_dependent?Boolean

Returns:

  • (Boolean)


15
# File 'lib/opencdd/property_data_element_type.rb', line 15

def non_dependent? = @value == "NON_DEPENDENT_P_DET"

#to_sObject Also known as: inspect



23
# File 'lib/opencdd/property_data_element_type.rb', line 23

def to_s   = @value

#to_symObject



24
# File 'lib/opencdd/property_data_element_type.rb', line 24

def to_sym = @value.downcase.to_sym