rx-file/lib/rx-file/simple_node.rb

31 lines
752 B
Ruby
Raw Normal View History

2017-09-27 14:35:55 +02:00
module RxFile
2015-06-13 22:09:02 +02:00
# What makes a node simple is that it has no further structure
#
2015-06-15 07:21:15 +02:00
# This may mean number/string/symbol, but also tiny arrays or objects with
# very little attributes. In other words simple/object is not the same distinction
# as value/not value
2015-06-13 22:09:02 +02:00
class SimpleNode < Node
2015-06-15 07:21:15 +02:00
# data is a string that is written out in "out" function
def initialize data
super(nil) # simple nodes can not be referenced, always value
2015-06-13 22:09:02 +02:00
@data = data
end
2015-06-15 07:21:15 +02:00
# A SimpleNode is always simple (aha).
# accordingly there is no long_out
def is_simple?
true
end
private
2015-06-15 07:21:15 +02:00
# just write the data given in construcor. simple. hence the name.
def short_out io , level
io.write(@data)
2015-06-13 22:09:02 +02:00
end
end
2015-06-15 07:21:15 +02:00
2015-06-13 22:09:02 +02:00
end