Class: Kanrisuru::Remote::Fstab::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/kanrisuru/remote/fstab/entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Entry

Returns a new instance of Entry.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 10

def initialize(opts = {})
  @host = opts[:host]
  @line = opts[:line]

  @default = nil

  @device = opts[:device] || nil
  @opts = opts[:opts] || nil
  @label = opts[:label] || nil
  @uuid = opts[:uuid] || nil
  @mount_point = opts[:mount_point] || nil
  @type = opts[:type] || nil
  @freq = opts[:freq] || nil
  @passno = opts[:passno] || nil

  @changed = false

  @ucount = 0
  @special = false
  @invalid = false

  if Kanrisuru::Util.present?(@line) && @line.instance_of?(String)
    parse_line!
  elsif (Kanrisuru::Util.present?(@opts) && @opts.instance_of?(String)) || @opts.instance_of?(Hash)
    @opts = Kanrisuru::Remote::Fstab::Options.new(@type, @opts)
  end
end

Instance Attribute Details

#deviceObject (readonly)

Returns the value of attribute device.



7
8
9
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 7

def device
  @device
end

#freqObject (readonly)

Returns the value of attribute freq.



7
8
9
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 7

def freq
  @freq
end

#invalidObject (readonly)

Returns the value of attribute invalid.



7
8
9
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 7

def invalid
  @invalid
end

#labelObject (readonly)

Returns the value of attribute label.



7
8
9
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 7

def label
  @label
end

#mount_pointObject

Returns the value of attribute mount_point.



8
9
10
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 8

def mount_point
  @mount_point
end

#optsObject (readonly)

Returns the value of attribute opts.



7
8
9
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 7

def opts
  @opts
end

#passnoObject (readonly)

Returns the value of attribute passno.



7
8
9
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 7

def passno
  @passno
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 7

def type
  @type
end

#uuidObject (readonly)

Returns the value of attribute uuid.



7
8
9
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 7

def uuid
  @uuid
end

Instance Method Details

#inspectObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 38

def inspect
  str = '#<Kanrisuru::Remote::Fstab::Entry:0x%<object_id>s ' \
        '@line=%<line>s @device=%<device>s @label=%<label>s' \
        '@uuid=%<uuid>s @freq=%<freq>s @pasno=%<passno>s' \
        '@opts=%<opts>s}>'

  format(
    str,
    object_id: object_id,
    line: @line,
    device: @device,
    label: @label,
    uuid: @uuid,
    freq: @freq,
    passno: @passno,
    opts: @opts.inspect
  )
end

#to_s(override = nil) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 61

def to_s(override = nil)
  mode = override || @default

  case mode
  when 'uuid'
    "UUID=#{@uuid} #{@mount_point} #{@type} #{@opts} #{@freq} #{@passno}"
  when 'label'
    "LABEL=#{@label} #{@mount_point} #{@type} #{@opts} #{@freq} #{@passno}"
  else
    "#{@device} #{@mount_point} #{@type} #{@opts} #{@freq} #{@passno}"
  end
end

#valid?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/kanrisuru/remote/fstab/entry.rb', line 57

def valid?
  !@invalid
end