Class: PulpProxy::DiskUsage

Inherits:
Object
  • Object
show all
Includes:
Proxy::Log, Proxy::Util
Defined in:
lib/smart_proxy_pulp_plugin/disk_usage.rb

Constant Summary collapse

SIZE =
{ :byte => 1, :kilobyte => 1_024, :megabyte => 1_048_576, :gigabyte => 1_073_741_824, :terabyte => 1_099_511_627_776 }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ DiskUsage

Returns a new instance of DiskUsage.

Raises:

  • (::Proxy::Error::ConfigurationError)


9
10
11
12
13
14
15
16
17
18
# File 'lib/smart_proxy_pulp_plugin/disk_usage.rb', line 9

def initialize(opts ={})
  raise(::Proxy::Error::ConfigurationError, 'Unable to continue - must provide a path.') if opts[:path].nil?
  @paths_hash = validate_path(path_hash(opts[:path]))
  @path = @paths_hash.values
  @size_format = opts[:size] || :kilobyte
  @size = SIZE[@size_format]
  @stat = {}
  find_df
  get_stat
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/smart_proxy_pulp_plugin/disk_usage.rb', line 7

def path
  @path
end

#sizeObject (readonly)

Returns the value of attribute size.



7
8
9
# File 'lib/smart_proxy_pulp_plugin/disk_usage.rb', line 7

def size
  @size
end

#statObject (readonly)

Returns the value of attribute stat.



7
8
9
# File 'lib/smart_proxy_pulp_plugin/disk_usage.rb', line 7

def stat
  @stat
end

Instance Method Details

#to_jsonObject



20
21
22
# File 'lib/smart_proxy_pulp_plugin/disk_usage.rb', line 20

def to_json
  stat.to_json
end