lib/drive_info.rb in sensible-cinema-0.19.3 vs lib/drive_info.rb in sensible-cinema-0.19.4
- old
+ new
@@ -15,10 +15,11 @@
You should have received a copy of the GNU General Public License
along with Sensible Cinema. If not, see <http://www.gnu.org/licenses/>.
=end
require 'digest/md5'
require 'ruby-wmi'
+require 'ostruct'
class DriveInfo
def self.md5sum_disk(dir)
digest = Digest::MD5.new()
@@ -28,12 +29,12 @@
}
raise 'drive might not yet have disc in it? ' + dir unless files.length > 0
digest.hexdigest
end
- def self.get_dvd_drives_as_win32ole
+ def self.get_dvd_drives_as_openstruct
disks = WMI::Win32_LogicalDisk.find(:all)
- disks.select{|d| d.Description =~ /CD-ROM/} # hope this works...
+ disks.select{|d| d.Description =~ /CD-ROM/}.map{|d| d2 = OpenStruct.new; d2.VolumeName = d.VolumeName; d2.Name = d.Name; d2}
end
def self.get_drive_with_most_space_with_slash
disks = WMI::Win32_LogicalDisk.find(:all)
most_space = disks.sort_by{|d| d.FreeSpace.to_i}[-1]