Class: Pubid::Components::Stage
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Pubid::Components::Stage
- Defined in:
- lib/pubid/components/stage.rb
Overview
Stage component (a set of defined stages)
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
Checks equality with another stage component.
-
#hash ⇒ Integer
Returns hash code for stage component.
- #render(context: nil) ⇒ Object
-
#to_s(context: nil, has_copublisher: false) ⇒ String
Render stage with optional context for flavor-specific separators.
Instance Method Details
#eql?(other) ⇒ Boolean
Checks equality with another stage component
47 48 49 50 51 |
# File 'lib/pubid/components/stage.rb', line 47 def eql?(other) return false unless other.is_a?(self.class) stage_code == other.stage_code && abbr == other.abbr end |
#hash ⇒ Integer
Note:
Memoized for performance
Returns hash code for stage component
40 41 42 |
# File 'lib/pubid/components/stage.rb', line 40 def hash @hash ||= [stage_code, abbr].compact.map(&:hash).hash end |
#render(context: nil) ⇒ Object
33 34 35 |
# File 'lib/pubid/components/stage.rb', line 33 def render(context: nil) abbr.to_s end |
#to_s(context: nil, has_copublisher: false) ⇒ String
Render stage with optional context for flavor-specific separators
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pubid/components/stage.rb', line 21 def to_s(context: nil, has_copublisher: false) return "" unless abbr if context sep = context.stage_separator_for(has_copublisher:) sep == "" ? abbr : "#{sep}#{abbr}" else # Default behavior: space after copublisher, slash otherwise has_copublisher ? " #{abbr}" : "/#{abbr}" end end |