Class: BinaryCodec::ComparableSerializedType
- Inherits:
-
SerializedType
- Object
- SerializedType
- BinaryCodec::ComparableSerializedType
- Defined in:
- lib/binary-codec/types/serialized_type.rb
Instance Attribute Summary
Attributes inherited from SerializedType
Instance Method Summary collapse
-
#compare_to(other) ⇒ Integer
Overload this method in subclasses to define comparison logic.
-
#eq(other) ⇒ Object
Compare if ‘self` is equal to `other`.
-
#gt(other) ⇒ Object
Compare if ‘self` is greater than `other`.
-
#gte(other) ⇒ Object
Compare if ‘self` is greater than or equal to `other`.
-
#lt(other) ⇒ Object
Compare if ‘self` is less than `other`.
-
#lte(other) ⇒ Object
Compare if ‘self` is less than or equal to `other`.
Methods inherited from SerializedType
from, from_bytes, from_hex, from_json, from_parser, get_type_by_name, #initialize, #to_byte_sink, #to_bytes, #to_hex, #to_json, #to_s
Constructor Details
This class inherits a constructor from BinaryCodec::SerializedType
Instance Method Details
#compare_to(other) ⇒ Integer
Overload this method in subclasses to define comparison logic
128 129 130 |
# File 'lib/binary-codec/types/serialized_type.rb', line 128 def compare_to(other) raise NotImplementedError, "Cannot compare #{self} and #{other}" end |
#eq(other) ⇒ Object
Compare if ‘self` is equal to `other`
105 106 107 |
# File 'lib/binary-codec/types/serialized_type.rb', line 105 def eq(other) compare_to(other) == 0 end |
#gt(other) ⇒ Object
Compare if ‘self` is greater than `other`
110 111 112 |
# File 'lib/binary-codec/types/serialized_type.rb', line 110 def gt(other) compare_to(other) > 0 end |
#gte(other) ⇒ Object
Compare if ‘self` is greater than or equal to `other`
115 116 117 |
# File 'lib/binary-codec/types/serialized_type.rb', line 115 def gte(other) compare_to(other) >= 0 end |
#lt(other) ⇒ Object
Compare if ‘self` is less than `other`
100 101 102 |
# File 'lib/binary-codec/types/serialized_type.rb', line 100 def lt(other) compare_to(other) < 0 end |
#lte(other) ⇒ Object
Compare if ‘self` is less than or equal to `other`
120 121 122 |
# File 'lib/binary-codec/types/serialized_type.rb', line 120 def lte(other) compare_to(other) <= 0 end |