Class: OsCtld::Transfer::Log
- Inherits:
-
Object
- Object
- OsCtld::Transfer::Log
- Defined in:
- lib/osctld/transfer/log.rb
Direct Known Subclasses
Constant Summary collapse
- STATES =
%i[stage base incremental transfer cleanup].freeze
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#snapshots ⇒ Object
readonly
Returns the value of attribute snapshots.
-
#state ⇒ Object
Returns the value of attribute state.
-
#state_running ⇒ Object
Returns the value of attribute state_running.
-
#state_snapshot ⇒ Object
Returns the value of attribute state_snapshot.
Instance Method Summary collapse
- #can_cancel?(force = false) ⇒ Boolean
- #can_continue?(next_state, sync_states: %i[base incremental])) ⇒ Boolean
-
#initialize(opts) ⇒ Log
constructor
A new instance of Log.
Constructor Details
#initialize(opts) ⇒ Log
Returns a new instance of Log.
10 11 12 13 14 15 16 17 |
# File 'lib/osctld/transfer/log.rb', line 10 def initialize(opts) @role = opts[:role] @state = opts[:state] || :stage @snapshots = opts[:snapshots] || [] @state_snapshot = opts[:state_snapshot] @state_running = opts[:state_running] @opts = opts[:opts] end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
7 8 9 |
# File 'lib/osctld/transfer/log.rb', line 7 def opts @opts end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
7 8 9 |
# File 'lib/osctld/transfer/log.rb', line 7 def role @role end |
#snapshots ⇒ Object (readonly)
Returns the value of attribute snapshots.
7 8 9 |
# File 'lib/osctld/transfer/log.rb', line 7 def snapshots @snapshots end |
#state ⇒ Object
Returns the value of attribute state.
7 8 9 |
# File 'lib/osctld/transfer/log.rb', line 7 def state @state end |
#state_running ⇒ Object
Returns the value of attribute state_running.
8 9 10 |
# File 'lib/osctld/transfer/log.rb', line 8 def state_running @state_running end |
#state_snapshot ⇒ Object
Returns the value of attribute state_snapshot.
8 9 10 |
# File 'lib/osctld/transfer/log.rb', line 8 def state_snapshot @state_snapshot end |
Instance Method Details
#can_cancel?(force = false) ⇒ Boolean
33 34 35 36 37 |
# File 'lib/osctld/transfer/log.rb', line 33 def can_cancel?(force = false) cancellable = %i[stage base incremental] cancellable << :transfer if force cancellable.include?(state) end |
#can_continue?(next_state, sync_states: %i[base incremental])) ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/osctld/transfer/log.rb', line 19 def can_continue?(next_state, sync_states: %i[base incremental]) cur_i = STATES.index(state) next_i = STATES.index(next_state) if !cur_i || !next_i false elsif (state == :cleanup && next_state == :cleanup) || (sync_states.include?(state) && sync_states.include?(next_state)) true else next_i > cur_i end end |