Class: Pubid::Nist::Components::Part
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Pubid::Nist::Components::Part
- Defined in:
- lib/pubid/nist/components/part.rb
Overview
Part component for NIST publications Format: nNUMBER, ptNUMBER, or just letter depending on type
Type attribute determines rendering:
- "pt" => "pt1" (SP part notation)
- "n" => "n1" (CSM issue notation)
- "" => "A" (letter suffix - just the letter)
Examples:
Part.new(type: "pt", value: "1").to_s => "pt1"
Part.new(type: "n", value: "1").to_s => "n1"
Part.new(type: "", value: "A").to_s => "A"
Used in:
- CSM: Issue number (n1)
- SP: Part number (pt1)
- Letter suffixes (A, B, C, etc.)
Instance Method Summary collapse
-
#to_i ⇒ Object
Alias for numeric comparison.
-
#to_s(notation = nil) ⇒ String
Render part with type-specific notation.
Instance Method Details
#to_i ⇒ Object
Alias for numeric comparison
71 72 73 |
# File 'lib/pubid/nist/components/part.rb', line 71 def to_i value.to_i end |
#to_s(notation = nil) ⇒ String
Render part with type-specific notation
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pubid/nist/components/part.rb', line 35 def to_s(notation = nil) # Handle symbol notation parameters notation_to_use = if notation.is_a?(Symbol) case notation when :n_notation then "n" when :pt_notation then "pt" when :letter_notation then "" else notation.to_s end else notation end # If notation explicitly provided, use it if notation_to_use return "#{notation_to_use}#{value}" unless notation_to_use.empty? return value end # Otherwise use type attribute case type when "pt" "pt#{value}" when "n" "n#{value}" when "" # Letter suffix - just the letter value else # Fallback for nil or unknown types - default to "n" notation (CSM issue number) "n#{value}" end end |