Class: Raft::LogEntry
- Inherits:
-
Object
- Object
- Raft::LogEntry
- Defined in:
- lib/raft.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#term ⇒ Object
readonly
Returns the value of attribute term.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(term, index, command) ⇒ LogEntry
constructor
A new instance of LogEntry.
Constructor Details
#initialize(term, index, command) ⇒ LogEntry
Returns a new instance of LogEntry.
21 22 23 |
# File 'lib/raft.rb', line 21 def initialize(term, index, command) @term, @index, @command = term, index, command end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
19 20 21 |
# File 'lib/raft.rb', line 19 def command @command end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
19 20 21 |
# File 'lib/raft.rb', line 19 def index @index end |
#term ⇒ Object (readonly)
Returns the value of attribute term.
19 20 21 |
# File 'lib/raft.rb', line 19 def term @term end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 28 29 |
# File 'lib/raft.rb', line 25 def ==(other) [:term, :index, :command].all? do |attr| self.send(attr) == other.send(attr) end end |
#eql?(other) ⇒ Boolean
31 32 33 |
# File 'lib/raft.rb', line 31 def eql?(other) self == other end |
#hash ⇒ Object
35 36 37 38 39 |
# File 'lib/raft.rb', line 35 def hash [:term, :index, :command].reduce(0) do |h, attr| h ^= self.send(attr) end end |