Class: Diskman::Device
- Inherits:
-
Object
- Object
- Diskman::Device
- Defined in:
- lib/diskman/device.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #get_clone_command(path) ⇒ Object
- #get_fdisk_command ⇒ Object
- #get_mkfs_command(fs) ⇒ Object
- #get_write_command(path) ⇒ Object
-
#initialize(name) ⇒ Device
constructor
A new instance of Device.
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Device
Returns a new instance of Device.
6 7 8 9 |
# File 'lib/diskman/device.rb', line 6 def initialize(name) @name = name @path = '/dev/' + name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/diskman/device.rb', line 3 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/diskman/device.rb', line 4 def path @path end |
Instance Method Details
#get_clone_command(path) ⇒ Object
24 25 26 27 |
# File 'lib/diskman/device.rb', line 24 def get_clone_command(path) dd = 'sudo dd if="%s" of="%s" bs=%dM status=progress conv=fsync' dd % [@path, path, 4] end |
#get_fdisk_command ⇒ Object
11 12 13 |
# File 'lib/diskman/device.rb', line 11 def get_fdisk_command 'sudo fdisk %s' % @path end |
#get_mkfs_command(fs) ⇒ Object
15 16 17 |
# File 'lib/diskman/device.rb', line 15 def get_mkfs_command(fs) 'sudo mkfs.%s %s' % [fs, @path] end |
#get_write_command(path) ⇒ Object
19 20 21 22 |
# File 'lib/diskman/device.rb', line 19 def get_write_command(path) dd = 'sudo dd if="%s" of="%s" bs=%dM status=progress conv=fsync' dd % [path, @path, 4] end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/diskman/device.rb', line 29 def to_s @path end |