Class: RFuse::StatVfs

Inherits:
Object
  • Object
show all
Defined in:
lib/rfuse/statvfs.rb

Overview

Helper class to return from :statfs (eg for df output) All attributes are Integers and default to 0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values = {}) ⇒ StatVfs

values can be symbols or strings but drop the pointless f_ prefix



13
14
15
16
17
18
19
20
21
# File 'lib/rfuse/statvfs.rb', line 13

def initialize(values = {})
  @f_bsize, @f_frsize, @f_blocks, @f_bfree, @f_bavail, @f_files, @f_ffree, @f_favail, @f_fsid, @f_flag, @f_namemax = Array.new(
    13, 0
  )
  values.each_pair do |k, v|
    prefix = k.to_s.start_with?('f_') ? '' : 'f_'
    instance_variable_set("@#{prefix}#{k}", v)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



27
28
29
30
31
# File 'lib/rfuse/statvfs.rb', line 27

def method_missing(method, *args)
  return super if method.start_with?('f_')

  send("f_#{method}", *args)
end

Instance Attribute Details

#f_bavailInteger

Returns:

  • (Integer)


7
8
9
# File 'lib/rfuse/statvfs.rb', line 7

def f_bavail
  @f_bavail
end

#f_bfreeInteger

Returns:

  • (Integer)


7
8
9
# File 'lib/rfuse/statvfs.rb', line 7

def f_bfree
  @f_bfree
end

#f_blocksInteger

Returns:

  • (Integer)


7
8
9
# File 'lib/rfuse/statvfs.rb', line 7

def f_blocks
  @f_blocks
end

#f_bsizeInteger

Returns:

  • (Integer)


7
8
9
# File 'lib/rfuse/statvfs.rb', line 7

def f_bsize
  @f_bsize
end

#f_favailInteger

Returns:

  • (Integer)


10
11
12
# File 'lib/rfuse/statvfs.rb', line 10

def f_favail
  @f_favail
end

#f_ffreeInteger

Returns:

  • (Integer)


10
11
12
# File 'lib/rfuse/statvfs.rb', line 10

def f_ffree
  @f_ffree
end

#f_filesInteger

Returns:

  • (Integer)


10
11
12
# File 'lib/rfuse/statvfs.rb', line 10

def f_files
  @f_files
end

#f_flagInteger

Returns:

  • (Integer)


10
11
12
# File 'lib/rfuse/statvfs.rb', line 10

def f_flag
  @f_flag
end

#f_frsizeInteger

Returns:

  • (Integer)


7
8
9
# File 'lib/rfuse/statvfs.rb', line 7

def f_frsize
  @f_frsize
end

#f_fsidInteger

Returns:

  • (Integer)


10
11
12
# File 'lib/rfuse/statvfs.rb', line 10

def f_fsid
  @f_fsid
end

#f_namemaxInteger

Returns:

  • (Integer)


10
11
12
# File 'lib/rfuse/statvfs.rb', line 10

def f_namemax
  @f_namemax
end

Instance Method Details

#respond_to_missing?(method, private = false) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/rfuse/statvfs.rb', line 23

def respond_to_missing?(method, private=false)
  !method.start_with?('f_') && respond_to?("f_#{method}", private)
end