Class: RTM::AR::Name

Inherits:
Reifiable show all
Includes:
Name
Defined in:
lib/rtm/activerecord/name_variant_occurrence.rb

Instance Method Summary collapse

Methods inherited from Reifiable

abstract_class?

Methods inherited from Construct

abstract_class?, find, wrap

Methods included from Construct

#find

Methods inherited from TMDelegator

#__getobj__, #__setobj__, aka_property, class_delegate, delegate, #eql?, equality, #hash, #initialize, parent, property, property_set, wrapper_cache

Constructor Details

This class inherits a constructor from RTM::AR::TMDelegator

Instance Method Details

#create_variant(arg1, arg2, arg3 = :nothing) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rtm/activerecord/name_variant_occurrence.rb', line 17

def create_variant(arg1, arg2, arg3 = :nothing)
  if arg1.is_a?(RTM::Locator)
    raise("create_variant(value,scope), value: Locator, scope must be an Array") unless arg2.is_a?(Array)
    if arg2.empty?
      raise("create_variant(value,scope), value: Locator, scope must not be empty")
    end
    arg2.each do |theme|
      raise("create_variant(value,scope), value: Locator, scope must contain Topic/Topic-References") unless (theme.is_a?(RTM::Topic) || theme.is_a?(String) || theme.is_a?(RTM::Locator))
    end
    return create_variant_internal(arg1, topic_map._topic_by_locator!(arg2) + self.scope.map{|t| t.__getobj__})
  elsif arg1.is_a?(String)
    if arg3 == :nothing 
      raise("create_variant(value,scope), value: String, scope must be an Array") unless arg2.is_a?(Array)
      if arg2.empty?
        raise("create_variant(value,scope), value: String, scope must not be empty")
      end
      arg2.each do |theme|
        raise("create_variant(value,scope), value: String, scope must contain Topic/Topic-References") unless (theme.is_a?(RTM::Topic) || theme.is_a?(String) || theme.is_a?(RTM::Locator))
      end
      return create_variant_internal(arg1, topic_map._topic_by_locator!(arg2) + self.scope.map{|t| t.__getobj__})
    elsif (arg2.is_a?(Locator) || arg2.is_a?(String))
      if ((arg2 == RTM::PSI[:String]) || (arg2 == topic_map.create_locator(RTM::PSI[:String])))
        return create_variant_internal(arg1, topic_map.create_locator(RTM::PSI[:String]), topic_map._topic_by_locator!(arg3) + self.scope.map{|t| t.__getobj__})
      elsif ((arg2 == RTM::PSI[:IRI]) || (arg2 == topic_map.create_locator(RTM::PSI[:IRI])))
        return create_variant_internal(arg1, topic_map.create_locator(RTM::PSI[:IRI]), topic_map._topic_by_locator!(arg3) + self.scope.map{|t| t.__getobj__})
      elsif ((arg2 == RTM::PSI[:XML]) || (arg2 == topic_map.create_locator(RTM::PSI[:XML])))
        return create_variant_internal(arg1, topic_map.create_locator(RTM::PSI[:XML]), topic_map._topic_by_locator!(arg3) + self.scope.map{|t| t.__getobj__})
      else 
        raise("create_variant(value,datatype,scope), value: String, unknown datatype")
      end
    else
      raise("create_variant(value,datatype,scope), datatype must be a String (identifier) or Locator")
    end 
  else
    raise "create_variant: value not a Locator or String"
  end  
end