Class: Pubid::Itu::Components::Sector
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Pubid::Itu::Components::Sector
- Defined in:
- lib/pubid/itu/components/sector.rb
Overview
ITU Sector component Values: R (Radio), T (Telecommunications), D (Development)
Constant Summary collapse
- VALID_SECTORS =
%w[R T D].freeze
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(attrs = {}, options = {}) ⇒ Sector
constructor
Accept either a positional Hash (lutaml-model's call style:
Sector.new({lutaml_register: :default})then attribute assignment) or a literalsector:kwarg (Sector.new(sector: "R")). - #to_s ⇒ Object
Constructor Details
#initialize(attrs = {}, options = {}) ⇒ Sector
Accept either a positional Hash (lutaml-model's call style:
Sector.new({lutaml_register: :default}) then attribute assignment)
or a literal sector: kwarg (Sector.new(sector: "R")). Both call
paths funnel through the same validate-then-set flow so the attribute
stays lutaml-tracked and round-trips through to_hash/from_hash.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pubid/itu/components/sector.rb', line 20 def initialize(attrs = {}, = {}) super sector_val = attrs[:sector] || attrs["sector"] return if sector_val.nil? normalized = sector_val.to_s.upcase unless VALID_SECTORS.include?(normalized) raise ArgumentError, "Invalid sector: #{sector_val}. Must be R, T, or D" end self.sector = normalized end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 41 42 |
# File 'lib/pubid/itu/components/sector.rb', line 38 def ==(other) return false unless other.is_a?(Sector) sector == other.sector end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/pubid/itu/components/sector.rb', line 34 def to_s sector end |