Class: Pubid::Iso::Components::Publisher
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Pubid::Iso::Components::Publisher
- Defined in:
- lib/pubid/iso/components/publisher.rb
Overview
ISO Publisher with copublisher support Examples: ISO, ISO/IEC, ISO/IEC/IEEE
Instance Method Summary collapse
- #==(other) ⇒ Object
- #body ⇒ Object
- #copublished? ⇒ Boolean
-
#eql?(other) ⇒ Boolean
Checks equality using hash for consistency.
- #has_copublisher? ⇒ Boolean
-
#hash ⇒ Integer
Returns hash code for publisher component.
- #render(context: nil) ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#==(other) ⇒ Object
38 39 40 41 42 |
# File 'lib/pubid/iso/components/publisher.rb', line 38 def ==(other) return false unless other.is_a?(Publisher) publisher == other.publisher && copublisher == other.copublisher end |
#body ⇒ Object
14 15 16 |
# File 'lib/pubid/iso/components/publisher.rb', line 14 def body publisher end |
#copublished? ⇒ Boolean
34 35 36 |
# File 'lib/pubid/iso/components/publisher.rb', line 34 def copublished? copublisher&.any? end |
#eql?(other) ⇒ Boolean
Checks equality using hash for consistency
54 55 56 |
# File 'lib/pubid/iso/components/publisher.rb', line 54 def eql?(other) hash == other.hash && self == other end |
#has_copublisher? ⇒ Boolean
30 31 32 |
# File 'lib/pubid/iso/components/publisher.rb', line 30 def has_copublisher? copublisher&.any? end |
#hash ⇒ Integer
Note:
Memoized for performance
Returns hash code for publisher component
47 48 49 |
# File 'lib/pubid/iso/components/publisher.rb', line 47 def hash @hash ||= [publisher, copublisher].compact.map(&:hash).hash end |
#render(context: nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/pubid/iso/components/publisher.rb', line 18 def render(context: nil) return publisher unless copublisher&.any? publisher + copublisher.map { |cp| "/#{cp}" }.join end |
#to_s ⇒ Object
24 25 26 27 28 |
# File 'lib/pubid/iso/components/publisher.rb', line 24 def to_s result = publisher result += copublisher.map { |cp| "/#{cp}" }.join if copublisher&.any? result end |