Class: Kanrisuru::Util::DmiType

Inherits:
Object
  • Object
show all
Defined in:
lib/kanrisuru/util/dmi_type.rb

Class Method Summary collapse

Class Method Details

.[](type) ⇒ Object



1345
1346
1347
1348
1349
1350
1351
1352
1353
# File 'lib/kanrisuru/util/dmi_type.rb', line 1345

def self.[](type)
  return unless valid?(type)

  if type.instance_of?(Integer)
    @dmi_types_inverted[type]
  else
    @dmi_types[type]
  end
end

.valid?(type) ⇒ Boolean

Returns:

  • (Boolean)


1355
1356
1357
1358
1359
1360
1361
1362
1363
# File 'lib/kanrisuru/util/dmi_type.rb', line 1355

def self.valid?(type)
  if type.instance_of?(Integer)
    @dmi_types_inverted.key?(type)
  elsif type.instance_of?(String)
    @dmi_types.key?(type)
  else
    raise ArgumentError, 'Invalid data type'
  end
end