Class: Restic::Service::Targets::Base
- Inherits:
-
Object
- Object
- Restic::Service::Targets::Base
- Defined in:
- lib/restic/service/targets/base.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #available? ⇒ Boolean
-
#initialize(name) ⇒ Base
constructor
A new instance of Base.
- #nice_commands ⇒ Object
- #setup_from_conf(conf, yaml) ⇒ Object
Constructor Details
#initialize(name) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 |
# File 'lib/restic/service/targets/base.rb', line 7 def initialize(name) @name = name @bandwidth_limit = nil @io_class = nil @io_priority = nil @cpu_priority = nil end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/restic/service/targets/base.rb', line 5 def name @name end |
Class Method Details
.normalize_yaml(yaml) ⇒ Object
15 16 17 |
# File 'lib/restic/service/targets/base.rb', line 15 def self.normalize_yaml(yaml) yaml.dup end |
Instance Method Details
#available? ⇒ Boolean
19 20 21 |
# File 'lib/restic/service/targets/base.rb', line 19 def available? true end |
#nice_commands ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/restic/service/targets/base.rb', line 39 def nice_commands result = [] if @io_class result << 'ionice' << '-c' << @io_class.to_s if @io_priority result << '-n' << @io_priority.to_s end end if @cpu_priority result << "nice" << "-#{@cpu_priority}" end result end |
#setup_from_conf(conf, yaml) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/restic/service/targets/base.rb', line 23 def setup_from_conf(conf, yaml) @bandwidth_limit = if limit = yaml.fetch('bandwidth_limit', conf.bandwidth_limit) Conf.parse_bandwidth_limit(limit) end if (io_class = yaml['io_class']) @io_class = Integer(io_class) end if (io_priority = yaml['io_priority']) @io_priority = Integer(io_priority) end if (cpu_priority = yaml['cpu_priority']) @cpu_priority = Integer(cpu_priority) end end |