Class: LinuxAdmin::FSTabEntry
- Inherits:
-
LinuxAdmin
- Object
- LinuxAdmin
- LinuxAdmin::FSTabEntry
- Defined in:
- lib/linux_admin/fstab.rb
Constant Summary
Constants inherited from LinuxAdmin
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#device ⇒ Object
Returns the value of attribute device.
-
#dumpable ⇒ Object
Returns the value of attribute dumpable.
-
#fs_type ⇒ Object
Returns the value of attribute fs_type.
-
#fsck_order ⇒ Object
Returns the value of attribute fsck_order.
-
#mount_options ⇒ Object
Returns the value of attribute mount_options.
-
#mount_point ⇒ Object
Returns the value of attribute mount_point.
Class Method Summary collapse
Instance Method Summary collapse
- #column_lengths ⇒ Object
- #columns ⇒ Object
- #formatted_columns(max_lengths) ⇒ Object
- #has_content? ⇒ Boolean
-
#initialize(args = {}) ⇒ FSTabEntry
constructor
A new instance of FSTabEntry.
Methods included from Common
Constructor Details
#initialize(args = {}) ⇒ FSTabEntry
Returns a new instance of FSTabEntry.
18 19 20 21 22 23 24 25 26 |
# File 'lib/linux_admin/fstab.rb', line 18 def initialize(args = {}) @device = args[:device] @mount_point = args[:mount_point] @fs_type = args[:fs_type] @mount_options = args[:mount_options] @dumpable = args[:dumpable].to_i unless args[:dumpable].nil? @fsck_order = args[:fsck_order].to_i unless args[:fsck_order].nil? @comment = args[:comment] end |
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
16 17 18 |
# File 'lib/linux_admin/fstab.rb', line 16 def comment @comment end |
#device ⇒ Object
Returns the value of attribute device.
10 11 12 |
# File 'lib/linux_admin/fstab.rb', line 10 def device @device end |
#dumpable ⇒ Object
Returns the value of attribute dumpable.
14 15 16 |
# File 'lib/linux_admin/fstab.rb', line 14 def dumpable @dumpable end |
#fs_type ⇒ Object
Returns the value of attribute fs_type.
12 13 14 |
# File 'lib/linux_admin/fstab.rb', line 12 def fs_type @fs_type end |
#fsck_order ⇒ Object
Returns the value of attribute fsck_order.
15 16 17 |
# File 'lib/linux_admin/fstab.rb', line 15 def fsck_order @fsck_order end |
#mount_options ⇒ Object
Returns the value of attribute mount_options.
13 14 15 |
# File 'lib/linux_admin/fstab.rb', line 13 def @mount_options end |
#mount_point ⇒ Object
Returns the value of attribute mount_point.
11 12 13 |
# File 'lib/linux_admin/fstab.rb', line 11 def mount_point @mount_point end |
Class Method Details
.from_line(fstab_line) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/linux_admin/fstab.rb', line 28 def self.from_line(fstab_line) columns, comment = fstab_line.split('#') comment = "##{comment}" unless comment.blank? columns = columns.chomp.split FSTabEntry.new :device => columns[0], :mount_point => columns[1], :fs_type => columns[2], :mount_options => columns[3], :dumpable => columns[4], :fsck_order => columns[5], :comment => comment end |
Instance Method Details
#column_lengths ⇒ Object
51 52 53 |
# File 'lib/linux_admin/fstab.rb', line 51 def column_lengths self.columns.collect { |c| c ? c.size : 0 } end |
#columns ⇒ Object
46 47 48 49 |
# File 'lib/linux_admin/fstab.rb', line 46 def columns [self.device, self.mount_point, self.fs_type, self., self.dumpable, self.fsck_order, self.comment] end |
#formatted_columns(max_lengths) ⇒ Object
55 56 57 58 |
# File 'lib/linux_admin/fstab.rb', line 55 def formatted_columns(max_lengths) self.columns.collect. with_index { |col, i| col.to_s.rjust(max_lengths[i]) }.join(" ") end |
#has_content? ⇒ Boolean
42 43 44 |
# File 'lib/linux_admin/fstab.rb', line 42 def has_content? !self.columns.first.nil? end |