Module: RTM::IO::ToHash::Name

Defined in:
lib/rtm/io/to_hash.rb

Instance Method Summary collapse

Instance Method Details

#to_hashObject

Returns the Hash representation of this name.

The returned Hash holds information about the :reifier, the :item_identifiers, the :value, the :type, the :scope and the :variants.

:call-seq:

to_hash -> Hash


59
60
61
62
63
64
65
66
67
68
# File 'lib/rtm/io/to_hash.rb', line 59

def to_hash
  h={}
  h[:reifier] = reifier.reference if reifier
  h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
  h[:value] = value if value
  h[:type] = type.reference if type
  h[:scope] = scope.map{|i| i.reference} unless scope.empty?
  h[:variants] = variants.map{|i| i.to_hash} unless variants.empty?
  h
end