supressing nil attributes on objects

This commit is contained in:
Torsten Ruger
2014-08-20 22:33:08 +03:00
parent 1371d395ec
commit 9608e5f626
3 changed files with 12 additions and 5 deletions

View File

@ -35,10 +35,11 @@ module Sof
return SimpleNode.new( object.name )
end
head = object.class.name + "("
atts = attributes_for(object).inject({}) do |hash , a|
atts = {}
attributes_for(object).each() do |a|
val = get_value(object , a)
hash[a] = to_sof_node(val , level + 1)
hash
next if val.nil?
atts[a] = to_sof_node(val , level + 1)
end
immediate , extended = atts.partition {|a,val| val.is_a?(SimpleNode) }
head += immediate.collect {|a,val| "#{a.to_sof()} => #{val.data}"}.join(", ") + ")"

View File

@ -83,5 +83,11 @@ module Virtual
end
attr_reader :to , :from
end
class ObjectGet < Instruction
def initialize name
@name = name.to_sym
end
attr_reader :name
end
end