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
selfis equal toother. -
#gt(other) ⇒ Object
Compare if
selfis greater thanother. -
#gte(other) ⇒ Object
Compare if
selfis greater than or equal toother. -
#lt(other) ⇒ Object
Compare if
selfis less thanother. -
#lte(other) ⇒ Object
Compare if
selfis less than or equal toother.
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, #value_of
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
155 156 157 |
# File 'lib/binary-codec/types/serialized_type.rb', line 155 def compare_to(other) raise NotImplementedError, "Cannot compare #{self} and #{other}" end |
#eq(other) ⇒ Object
Compare if self is equal to other
132 133 134 |
# File 'lib/binary-codec/types/serialized_type.rb', line 132 def eq(other) compare_to(other) == 0 end |
#gt(other) ⇒ Object
Compare if self is greater than other
137 138 139 |
# File 'lib/binary-codec/types/serialized_type.rb', line 137 def gt(other) compare_to(other) > 0 end |
#gte(other) ⇒ Object
Compare if self is greater than or equal to other
142 143 144 |
# File 'lib/binary-codec/types/serialized_type.rb', line 142 def gte(other) compare_to(other) >= 0 end |
#lt(other) ⇒ Object
Compare if self is less than other
127 128 129 |
# File 'lib/binary-codec/types/serialized_type.rb', line 127 def lt(other) compare_to(other) < 0 end |
#lte(other) ⇒ Object
Compare if self is less than or equal to other
147 148 149 |
# File 'lib/binary-codec/types/serialized_type.rb', line 147 def lte(other) compare_to(other) <= 0 end |