Class: Diskman::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/diskman/device.rb

Direct Known Subclasses

RootDevice

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/diskman/device.rb', line 3

def name
  @name
end

#pathObject (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_commandObject



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_sObject



29
30
31
# File 'lib/diskman/device.rb', line 29

def to_s
    @path
end