Class: Opencdd::PropertyDataTypeElement
- Inherits:
-
Object
- Object
- Opencdd::PropertyDataTypeElement
- 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
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #condition? ⇒ Boolean
- #conditional? ⇒ Boolean
- #dependent? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(value) ⇒ PropertyDataTypeElement
constructor
A new instance of PropertyDataTypeElement.
- #non_dependent? ⇒ Boolean
- #to_s ⇒ Object (also: #inspect)
- #to_sym ⇒ Object
Constructor Details
#initialize(value) ⇒ PropertyDataTypeElement
Returns a new instance of PropertyDataTypeElement.
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
#value ⇒ Object (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
16 |
# File 'lib/opencdd/property_data_element_type.rb', line 16 def condition? = @value == "CONDITION_DET" |
#conditional? ⇒ Boolean
19 20 21 |
# File 'lib/opencdd/property_data_element_type.rb', line 19 def conditional? condition? || dependent? end |
#dependent? ⇒ Boolean
17 |
# File 'lib/opencdd/property_data_element_type.rb', line 17 def dependent? = @value == "DEPENDENT_P_DET" |
#hash ⇒ Object
31 32 33 |
# File 'lib/opencdd/property_data_element_type.rb', line 31 def hash @value.hash end |
#non_dependent? ⇒ Boolean
15 |
# File 'lib/opencdd/property_data_element_type.rb', line 15 def non_dependent? = @value == "NON_DEPENDENT_P_DET" |
#to_s ⇒ Object Also known as: inspect
23 |
# File 'lib/opencdd/property_data_element_type.rb', line 23 def to_s = @value |
#to_sym ⇒ Object
24 |
# File 'lib/opencdd/property_data_element_type.rb', line 24 def to_sym = @value.downcase.to_sym |