Method: Quantify::Unit::Base#to_hash

Defined in:
lib/quantify/unit/base_unit.rb

#to_hashObject

Return a hash representation of self containing each unit attribute (i.e each instance variable)



514
515
516
517
518
519
520
521
# File 'lib/quantify/unit/base_unit.rb', line 514

def to_hash
  hash = {}
  self.instance_variables.each do |var|
    symbol = var.to_s.gsub("@","").to_sym
    hash[symbol] = send symbol
  end
  return hash
end