class Sfp::SasTranslator::ValueCollector
Collects all values (primitive or non-primitive)
Public Class Methods
new(sas)
click to toggle source
# File lib/sfp/sas_translator.rb, line 1749 def initialize(sas) @bucket = sas.types @sas = sas end
Public Instance Methods
get_type(value)
click to toggle source
# File lib/sfp/sas_translator.rb, line 1789 def get_type(value) if value.is_a?(String) and not value.isref '$.String' elsif value.is_a?(Numeric) '$.Integer' elsif value.is_a?(TrueClass) or value.is_a?(FalseClass) '$.Boolean' else nil end end
visit(name, value, obj)
click to toggle source
# File lib/sfp/sas_translator.rb, line 1754 def visit(name, value, obj) return true if name[0,1] == '_' and name != '_value' type = get_type(value) if type != nil @bucket[type] << value elsif value.is_a?(Hash) if value.isobject value['_classes'].each { |c| @bucket[c] << value } elsif value.isset raise TranslationException, 'not implemented -- set: ' + value['_isa'] end elsif value.is_a?(Array) if value.length > 0 type = get_type(value[0]) if type != nil type = "(#{type})" # an array #raise Exception, "type not found: #{type}" if not @bucket.has_key?(type) @bucket[type] = [] if not @bucket.has_key?(type) @bucket["#{type}"] << value elsif value[0].is_a?(String) and value[0].isref val = @sas.root['initial'].at?(value[0]) return true if val == nil type = get_type(val) if type != nil @bucket["(#{type})"] << value elsif val.is_a?(Hash) and val.isobject val['_classes'].each { |c| @bucket["(#{c})"] << value if @bucket.has_key?("(#{c})") } end end end else end return true end