Class: LinuxAdmin::FSTabEntry
- Inherits:
-
Object
- Object
- LinuxAdmin::FSTabEntry
- Defined in:
- lib/linux_admin/fstab.rb
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.
Constructor Details
#initialize(args = {}) ⇒ FSTabEntry
Returns a new instance of FSTabEntry.
13 14 15 16 17 18 19 20 21 |
# File 'lib/linux_admin/fstab.rb', line 13 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.
11 12 13 |
# File 'lib/linux_admin/fstab.rb', line 11 def comment @comment end |
#device ⇒ Object
Returns the value of attribute device.
5 6 7 |
# File 'lib/linux_admin/fstab.rb', line 5 def device @device end |
#dumpable ⇒ Object
Returns the value of attribute dumpable.
9 10 11 |
# File 'lib/linux_admin/fstab.rb', line 9 def dumpable @dumpable end |
#fs_type ⇒ Object
Returns the value of attribute fs_type.
7 8 9 |
# File 'lib/linux_admin/fstab.rb', line 7 def fs_type @fs_type end |
#fsck_order ⇒ Object
Returns the value of attribute fsck_order.
10 11 12 |
# File 'lib/linux_admin/fstab.rb', line 10 def fsck_order @fsck_order end |
#mount_options ⇒ Object
Returns the value of attribute mount_options.
8 9 10 |
# File 'lib/linux_admin/fstab.rb', line 8 def @mount_options end |
#mount_point ⇒ Object
Returns the value of attribute mount_point.
6 7 8 |
# File 'lib/linux_admin/fstab.rb', line 6 def mount_point @mount_point end |
Class Method Details
.from_line(fstab_line) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/linux_admin/fstab.rb', line 23 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
46 47 48 |
# File 'lib/linux_admin/fstab.rb', line 46 def column_lengths columns.collect { |c| c ? c.to_s.size : 0 } end |
#columns ⇒ Object
41 42 43 44 |
# File 'lib/linux_admin/fstab.rb', line 41 def columns [self.device, self.mount_point, self.fs_type, self., self.dumpable, self.fsck_order, self.comment] end |
#formatted_columns(max_lengths) ⇒ Object
50 51 52 53 |
# File 'lib/linux_admin/fstab.rb', line 50 def formatted_columns(max_lengths) self.columns.collect. with_index { |col, i| col.to_s.rjust(max_lengths[i]) }.join(" ").rstrip end |
#has_content? ⇒ Boolean
37 38 39 |
# File 'lib/linux_admin/fstab.rb', line 37 def has_content? !self.columns.first.nil? end |