Class: Clerq::Services::ReadNode
- Defined in:
- lib/clerq/services/read_node.rb
Overview
The service reads nodes from file and returns array of nodes It returns array because the file can have a few root nodes
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(filename, on_error = nil) ⇒ ReadNode
constructor
A new instance of ReadNode.
Methods inherited from Service
Constructor Details
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/clerq/services/read_node.rb', line 13 def call # FIXME: something wrong here when foreach! # text = File.read(@filename) read_nodes(text) do |node_text| level, node = parse_node(node_text) next unless node node[:filename] = @filename insert_node(node, level) end ary = Array.new(@node.items) ary.each(&:orphan!) ary end |