Sha256: 1191c812eb09e55b1501027914d769142bca28c9eafeefe77a0731b573bd8454

Contents?: true

Size: 666 Bytes

Versions: 3

Compression:

Stored size: 666 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/console/speaker/node'

module EacRubyUtils
  module Console
    module Speaker
      class << self
        def current_node
          nodes_stack.last
        end

        def push
          nodes_stack << ::EacRubyUtils::Console::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 ||= [::EacRubyUtils::Console::Speaker::Node.new]
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eac_ruby_utils-0.17.0 lib/eac_ruby_utils/console/speaker/_class_methods.rb
eac_ruby_utils-0.16.0 lib/eac_ruby_utils/console/speaker/_class_methods.rb
eac_ruby_utils-0.15.0 lib/eac_ruby_utils/console/speaker/_class_methods.rb