Class: JobDispatch::Identity
- Inherits:
-
Object
- Object
- JobDispatch::Identity
- Includes:
- Comparable
- Defined in:
- lib/job_dispatch/identity.rb
Overview
Identity encapsulates a ZeroMQ socket identity, which is a string of binary characters, typically containing nulls or non-utf8 compatible characters in ASCII-8BIT encoding.
Instance Attribute Summary collapse
-
#identity ⇒ Object
readonly
Returns the value of attribute identity.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #as_json(options = {}) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(identity) ⇒ Identity
constructor
A new instance of Identity.
- #to_hex ⇒ Object
- #to_s ⇒ Object
- #to_str ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(identity) ⇒ Identity
Returns a new instance of Identity.
13 14 15 |
# File 'lib/job_dispatch/identity.rb', line 13 def initialize(identity) @identity = identity.to_sym end |
Instance Attribute Details
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
11 12 13 |
# File 'lib/job_dispatch/identity.rb', line 11 def identity @identity end |
Instance Method Details
#<=>(other) ⇒ Object
49 50 51 |
# File 'lib/job_dispatch/identity.rb', line 49 def <=>(other) @identity <=> other.identity end |
#==(other) ⇒ Object
41 42 43 |
# File 'lib/job_dispatch/identity.rb', line 41 def ==(other) @identity == other.identity end |
#as_json(options = {}) ⇒ Object
29 30 31 |
# File 'lib/job_dispatch/identity.rb', line 29 def as_json(={}) to_hex.as_json() end |
#eql?(other) ⇒ Boolean
45 46 47 |
# File 'lib/job_dispatch/identity.rb', line 45 def eql?(other) self.class == other.class && @identity == other.identity end |
#hash ⇒ Object
37 38 39 |
# File 'lib/job_dispatch/identity.rb', line 37 def hash @identity.hash end |
#to_hex ⇒ Object
25 26 27 |
# File 'lib/job_dispatch/identity.rb', line 25 def to_hex @identity.to_s.bytes.map { |x| '%02x' % x }.join end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/job_dispatch/identity.rb', line 17 def to_s @identity.to_s end |
#to_str ⇒ Object
21 22 23 |
# File 'lib/job_dispatch/identity.rb', line 21 def to_str @identity.to_str end |
#to_sym ⇒ Object
33 34 35 |
# File 'lib/job_dispatch/identity.rb', line 33 def to_sym @identity end |