lib/node.rb in rna-0.3.5 vs lib/node.rb in rna-0.3.6
- old
+ new
@@ -4,14 +4,10 @@
class Attribute
attr_reader :value
def initialize(value)
@value = value
end
- def [](key)
- puts "Node::Attribute key #{key}"
- nil
- end
end
def initialize
@data = {}
super
@@ -24,19 +20,19 @@
@data[key] = attribute
end
def [](key)
key = convert_key(key)
- if @data[key].nil?
- result = @data[key] = Node.new
- elsif @data[key].is_a?(Node::Attribute)
- result = @data[key].value
- elsif @data[key].is_a?(Node)
- result = @data[key]
+ case @data[key]
+ when nil
+ @data[key] = Node.new
+ when Node::Attribute
+ @data[key].value
+ when Node
+ @data[key]
else
raise "should never happen"
end
- result
end
def to_hash
hash = {}
@data.each do |key,item|