Class: Multicodecs::Registration

Inherits:
Object
  • Object
show all
Defined in:
lib/multicodecs/registry.rb

Overview

rubocop:enable Style/MutableConstant

Constant Summary collapse

STATUS_DRAFT =
'draft'
STATUS_PERMANENT =
'permanent'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, name:, tag:, status:, description:) ⇒ Registration

Returns a new instance of Registration.



22
23
24
25
26
27
28
# File 'lib/multicodecs/registry.rb', line 22

def initialize(code:, name:, tag:, status:, description:)
  self.code = code
  self.name = name
  self.tag = tag
  self.status = status
  self.description = description
end

Instance Attribute Details

#code ⇒ Object

Returns the value of attribute code.



20
21
22
# File 'lib/multicodecs/registry.rb', line 20

def code
  @code
end

#description ⇒ Object

Returns the value of attribute description.



20
21
22
# File 'lib/multicodecs/registry.rb', line 20

def description
  @description
end

#name ⇒ Object

Returns the value of attribute name.



20
21
22
# File 'lib/multicodecs/registry.rb', line 20

def name
  @name
end

#status ⇒ Object

Returns the value of attribute status.



20
21
22
# File 'lib/multicodecs/registry.rb', line 20

def status
  @status
end

#tag ⇒ Object

Returns the value of attribute tag.



20
21
22
# File 'lib/multicodecs/registry.rb', line 20

def tag
  @tag
end

Instance Method Details

#==(other) ⇒ Object



42
43
44
45
46
47
# File 'lib/multicodecs/registry.rb', line 42

def ==(other)
  return name == other if other.is_a?(String)
  return code == other if other.is_a?(Integer)

  eql?(other)
end

#draft? ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/multicodecs/registry.rb', line 34

def draft?
  status == STATUS_DRAFT
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/multicodecs/registry.rb', line 49

def eql?(other)
  other.is_a?(Registration) && other.name == name
end

#hash ⇒ Object



38
39
40
# File 'lib/multicodecs/registry.rb', line 38

def hash
  name.hash
end

#inspect ⇒ Object



57
58
59
# File 'lib/multicodecs/registry.rb', line 57

def inspect
  "#{to_s} #{name} (#{tag}/#{status}): #{description || '(no description)'}"
end

#permanent? ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/multicodecs/registry.rb', line 30

def permanent?
  status == STATUS_PERMANENT
end

#to_s ⇒ Object



53
54
55
# File 'lib/multicodecs/registry.rb', line 53

def to_s
  "0x#{code.to_s(16)}"
end