Class: Etwin::Link::VersionedHammerfestLink
- Inherits:
-
Object
- Object
- Etwin::Link::VersionedHammerfestLink
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/etwin/link/versioned_hammerfest_link.rb
Overview
Versioned Hammerfest link
Instance Attribute Summary collapse
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#old ⇒ Object
readonly
Returns the value of attribute old.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #as_json ⇒ Object
- #hash ⇒ Object
-
#initialize(current, old) ⇒ VersionedHammerfestLink
constructor
A new instance of VersionedHammerfestLink.
- #inspect ⇒ Object
-
#pretty_print(pp) ⇒ Object
rubocop:disable Metrics/MethodLength.
- #to_json(opts = nil) ⇒ Object
Constructor Details
#initialize(current, old) ⇒ VersionedHammerfestLink
Returns a new instance of VersionedHammerfestLink.
20 21 22 23 24 |
# File 'lib/etwin/link/versioned_hammerfest_link.rb', line 20 def initialize(current, old) @current = T.let(current, T.nilable(HammerfestLink)) @old = T.let(old.freeze, T::Array[HammerfestLink]) freeze end |
Instance Attribute Details
#current ⇒ Object (readonly)
Returns the value of attribute current.
14 15 16 |
# File 'lib/etwin/link/versioned_hammerfest_link.rb', line 14 def current @current end |
#old ⇒ Object (readonly)
Returns the value of attribute old.
17 18 19 |
# File 'lib/etwin/link/versioned_hammerfest_link.rb', line 17 def old @old end |
Class Method Details
.deserialize(raw) ⇒ Object
85 86 87 88 89 |
# File 'lib/etwin/link/versioned_hammerfest_link.rb', line 85 def deserialize(raw) raw_current = raw['current'] current = raw_current.nil? ? nil : HammerfestLink.deserialize(raw_current) new(current, []) end |
.from_json(json_str) ⇒ Object
80 81 82 |
# File 'lib/etwin/link/versioned_hammerfest_link.rb', line 80 def from_json(json_str) deserialize JSON.parse(json_str) end |
Instance Method Details
#==(other) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/etwin/link/versioned_hammerfest_link.rb', line 27 def ==(other) case other when VersionedHammerfestLink @current == other.current && @old == other.old else false end end |
#as_json ⇒ Object
48 49 50 51 52 53 |
# File 'lib/etwin/link/versioned_hammerfest_link.rb', line 48 def as_json { 'current' => @current.nil? ? nil : @current.as_json, 'old' => @old.map(&:as_json) } end |
#hash ⇒ Object
37 38 39 |
# File 'lib/etwin/link/versioned_hammerfest_link.rb', line 37 def hash [@current, @old].hash end |
#inspect ⇒ Object
56 57 58 |
# File 'lib/etwin/link/versioned_hammerfest_link.rb', line 56 def inspect PP.singleline_pp(self, String.new) end |
#pretty_print(pp) ⇒ Object
rubocop:disable Metrics/MethodLength
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/etwin/link/versioned_hammerfest_link.rb', line 61 def pretty_print(pp) # rubocop:disable Metrics/MethodLength pp.group(0, "#{self.class.name}(", ')') do pp.nest 1 do pp.breakable '' pp.text 'current=' pp.pp @current pp.text ',' pp.breakable '' pp.text 'old=' pp.pp @old end pp.breakable '' end end |
#to_json(opts = nil) ⇒ Object
43 44 45 |
# File 'lib/etwin/link/versioned_hammerfest_link.rb', line 43 def to_json(opts = nil) JSON.generate(as_json, opts) end |