Class: Etwin::Link::VersionedLinks

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/etwin/link/versioned_links.rb

Overview

Versioned Eternal-Twin links

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hammerfest_es, hammerfest_fr, hfest_net, twinoid) ⇒ VersionedLinks

Returns a new instance of VersionedLinks.



33
34
35
36
37
38
39
# File 'lib/etwin/link/versioned_links.rb', line 33

def initialize(hammerfest_es, hammerfest_fr, hfest_net, twinoid)
  @hammerfest_es = T.let(hammerfest_es, VersionedHammerfestLink)
  @hammerfest_fr = T.let(hammerfest_fr, VersionedHammerfestLink)
  @hfest_net = T.let(hfest_net, VersionedHammerfestLink)
  @twinoid = T.let(twinoid, VersionedTwinoidLink)
  freeze
end

Instance Attribute Details

#hammerfest_esObject (readonly)

Returns the value of attribute hammerfest_es.



14
15
16
# File 'lib/etwin/link/versioned_links.rb', line 14

def hammerfest_es
  @hammerfest_es
end

#hammerfest_frObject (readonly)

Returns the value of attribute hammerfest_fr.



17
18
19
# File 'lib/etwin/link/versioned_links.rb', line 17

def hammerfest_fr
  @hammerfest_fr
end

#hfest_netObject (readonly)

Returns the value of attribute hfest_net.



20
21
22
# File 'lib/etwin/link/versioned_links.rb', line 20

def hfest_net
  @hfest_net
end

#twinoidObject (readonly)

Returns the value of attribute twinoid.



23
24
25
# File 'lib/etwin/link/versioned_links.rb', line 23

def twinoid
  @twinoid
end

Class Method Details

.deserialize(raw) ⇒ Object



113
114
115
116
117
118
119
# File 'lib/etwin/link/versioned_links.rb', line 113

def deserialize(raw)
  hammerfest_es = VersionedHammerfestLink.deserialize(raw['hammerfest_es'])
  hammerfest_fr = VersionedHammerfestLink.deserialize(raw['hammerfest_fr'])
  hfest_net = VersionedHammerfestLink.deserialize(raw['hfest_net'])
  twinoid = VersionedTwinoidLink.deserialize(raw['twinoid'])
  new(hammerfest_es, hammerfest_fr, hfest_net, twinoid)
end

.from_json(json_str) ⇒ Object



108
109
110
# File 'lib/etwin/link/versioned_links.rb', line 108

def from_json(json_str)
  deserialize JSON.parse(json_str)
end

Instance Method Details

#==(other) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/etwin/link/versioned_links.rb', line 42

def ==(other)
  case other
  when VersionedLinks
    @hammerfest_es == other.hammerfest_es &&
      @hammerfest_fr == other.hammerfest_fr &&
      @hfest_net == other.hfest_net &&
      @twinoid == other.twinoid
  else
    false
  end
end

#as_jsonObject



66
67
68
69
70
71
72
73
# File 'lib/etwin/link/versioned_links.rb', line 66

def as_json
  {
    'hammerfest_es' => @hammerfest_es.as_json,
    'hammerfest_fr' => @hammerfest_fr.as_json,
    'hfest_net' => @hfest_net.as_json,
    'twinoid' => @twinoid.as_json
  }
end

#hashObject



55
56
57
# File 'lib/etwin/link/versioned_links.rb', line 55

def hash
  [@hammerfest_es, @hammerfest_fr, @hfest_net, @twinoid].hash
end

#inspectObject



76
77
78
# File 'lib/etwin/link/versioned_links.rb', line 76

def inspect
  PP.singleline_pp(self, String.new)
end

#pretty_print(pp) ⇒ Object

rubocop:disable Metrics/AbcSize, Metrics/MethodLength



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/etwin/link/versioned_links.rb', line 81

def pretty_print(pp)  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  pp.group(0, "#{self.class.name}(", ')') do
    pp.nest 1 do
      pp.breakable ''
      pp.text 'hammerfest_es='
      pp.pp @hammerfest_es
      pp.text ','
      pp.breakable ''
      pp.text 'hammerfest_fr='
      pp.pp @hammerfest_fr
      pp.text ','
      pp.breakable ''
      pp.text 'hfest_net='
      pp.pp @hfest_net
      pp.text ','
      pp.breakable ''
      pp.text 'twinoid='
      pp.pp @twinoid
    end
    pp.breakable ''
  end
end

#to_json(opts = nil) ⇒ Object



61
62
63
# File 'lib/etwin/link/versioned_links.rb', line 61

def to_json(opts = nil)
  JSON.generate(as_json, opts)
end