Sha256: f8beacd4595b3aa972c831b351a8a9c84553bb59ad67c891885051d1d4ad6478
Contents?: true
Size: 687 Bytes
Versions: 8
Compression:
Stored size: 687 Bytes
Contents
# frozen_string_literal: true require 'eac_cli/speaker/node' module EacCli module Speaker class << self def current_node nodes_stack.last end def on_node(&block) push yield(*(block.arity.zero? ? [] : [current_node])) ensure pop end def push nodes_stack << ::EacCli::Speaker::Node.new current_node end def pop return nodes_stack.pop if nodes_stack.count > 1 raise "Cannot remove first node (nodes_stack.count: #{nodes_stack.count})" end private def nodes_stack @nodes_stack ||= [::EacCli::Speaker::Node.new] end end end end
Version data entries
8 entries across 8 versions & 3 rubygems