Class: DiskID::DiskInfo
- Inherits:
-
Object
- Object
- DiskID::DiskInfo
- Defined in:
- lib/diskid.rb
Instance Attribute Summary collapse
-
#disk_size ⇒ Object
Returns the value of attribute disk_size.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#format ⇒ Object
Returns the value of attribute format.
-
#variant ⇒ Object
Returns the value of attribute variant.
-
#virtual_size ⇒ Object
Returns the value of attribute virtual_size.
Instance Method Summary collapse
-
#initialize(params) ⇒ DiskInfo
constructor
A new instance of DiskInfo.
- #to_hash ⇒ Object
- #to_json ⇒ Object
- #to_text ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(params) ⇒ DiskInfo
Returns a new instance of DiskInfo.
12 13 14 15 16 17 18 19 |
# File 'lib/diskid.rb', line 12 def initialize(params) @hash = params @file_name = @hash['file_name'] @format = @hash['format'] @virtual_size = @hash['virtual_size'] @disk_size = @hash['disk_size'] @variant = @hash['variant'] end |
Instance Attribute Details
#disk_size ⇒ Object
Returns the value of attribute disk_size.
9 10 11 |
# File 'lib/diskid.rb', line 9 def disk_size @disk_size end |
#file_name ⇒ Object
Returns the value of attribute file_name.
9 10 11 |
# File 'lib/diskid.rb', line 9 def file_name @file_name end |
#format ⇒ Object
Returns the value of attribute format.
9 10 11 |
# File 'lib/diskid.rb', line 9 def format @format end |
#variant ⇒ Object
Returns the value of attribute variant.
10 11 12 |
# File 'lib/diskid.rb', line 10 def variant @variant end |
#virtual_size ⇒ Object
Returns the value of attribute virtual_size.
9 10 11 |
# File 'lib/diskid.rb', line 9 def virtual_size @virtual_size end |
Instance Method Details
#to_hash ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/diskid.rb', line 46 def to_hash h = { 'file_name' => @file_name, 'format' => @format, 'virtual_size' => @virtual_size, 'disk_size' => @disk_size } h['variant'] = @variant if not @variant.empty? h end |
#to_json ⇒ Object
21 22 23 |
# File 'lib/diskid.rb', line 21 def to_json to_hash.to_json end |
#to_text ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/diskid.rb', line 37 def to_text t = "" t << "file_name: #{@file_name}\n" t << "format: #{@format}\n" t << "variant: #{@variant}\n" if not @variant.empty? t << "virtual_size: #{@virtual_size}\n" t << "disk_size: #{@disk_size}\n" end |
#to_xml ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/diskid.rb', line 25 def to_xml buf = "" buf << "<disk_info>" buf << "<file_name>#{@file_name}</file_name>" buf << "<format>#{@format}</format>" buf << "<variant>#{@variant}</variant>" if not @variant.empty? buf << "<virtual_size>#{@virtual_size}</virtual_size>" buf << "<disk_size>#{@disk_size}</disk_size>" buf << "</disk_info>" buf end |