Class: FreeDiskSpace
- Inherits:
-
Object
- Object
- FreeDiskSpace
- Defined in:
- lib/free_disk_space.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Class Method Summary collapse
- .bytes(dir) ⇒ Object
- .gigabytes(dir) ⇒ Object
- .kilobytes(dir) ⇒ Object
- .megabytes(dir) ⇒ Object
- .terabytes(dir) ⇒ Object
Instance Method Summary collapse
- #bytes ⇒ Object
- #gigabytes ⇒ Object
-
#initialize(dir) ⇒ FreeDiskSpace
constructor
A new instance of FreeDiskSpace.
- #kilobytes ⇒ Object
- #megabytes ⇒ Object
- #terabytes ⇒ Object
Constructor Details
#initialize(dir) ⇒ FreeDiskSpace
Returns a new instance of FreeDiskSpace.
7 8 9 |
# File 'lib/free_disk_space.rb', line 7 def initialize(dir) @dir = dir end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
5 6 7 |
# File 'lib/free_disk_space.rb', line 5 def dir @dir end |
Class Method Details
.bytes(dir) ⇒ Object
27 28 29 |
# File 'lib/free_disk_space.rb', line 27 def self.bytes(dir) new(dir).bytes end |
.gigabytes(dir) ⇒ Object
15 16 17 |
# File 'lib/free_disk_space.rb', line 15 def self.gigabytes(dir) new(dir).gigabytes end |
.kilobytes(dir) ⇒ Object
23 24 25 |
# File 'lib/free_disk_space.rb', line 23 def self.kilobytes(dir) new(dir).kilobytes end |
.megabytes(dir) ⇒ Object
19 20 21 |
# File 'lib/free_disk_space.rb', line 19 def self.megabytes(dir) new(dir).megabytes end |
.terabytes(dir) ⇒ Object
11 12 13 |
# File 'lib/free_disk_space.rb', line 11 def self.terabytes(dir) new(dir).terabytes end |
Instance Method Details
#bytes ⇒ Object
47 48 49 |
# File 'lib/free_disk_space.rb', line 47 def bytes filesystem_stat.block_size * filesystem_stat.blocks_available end |
#gigabytes ⇒ Object
35 36 37 |
# File 'lib/free_disk_space.rb', line 35 def gigabytes megabytes / 1024 end |
#kilobytes ⇒ Object
43 44 45 |
# File 'lib/free_disk_space.rb', line 43 def kilobytes bytes.to_f / 1024 end |
#megabytes ⇒ Object
39 40 41 |
# File 'lib/free_disk_space.rb', line 39 def megabytes kilobytes / 1024 end |
#terabytes ⇒ Object
31 32 33 |
# File 'lib/free_disk_space.rb', line 31 def terabytes gigabytes / 1024 end |