Sha256: 0188cfb58bc3697839756999e47601a3f662eff1871cd82497cc350ec792d51c

Contents?: true

Size: 945 Bytes

Versions: 31

Compression:

Stored size: 945 Bytes

Contents

module Aptible
  module CLI
    module Formatter
      class Root < Node
        attr_reader :root

        def initialize
          @root = nil
        end

        def value(s)
          assign_root(Value.new(s)) {}
        end

        def object(&block)
          assign_root(Object.new, &block)
        end

        def keyed_object(key, &block)
          assign_root(KeyedObject.new(key), &block)
        end

        def list(&block)
          assign_root(List.new, &block)
        end

        def keyed_list(key, &block)
          assign_root(KeyedList.new(key), &block)
        end

        def grouped_keyed_list(group, key, &block)
          assign_root(GroupedKeyedList.new(group, key), &block)
        end

        private

        def assign_root(node)
          raise "root has already been initialized: #{@root.inspect}" if @root
          yield node
          @root = node
          nil
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
aptible-cli-0.16.7 lib/aptible/cli/formatter/root.rb
aptible-cli-0.16.6 lib/aptible/cli/formatter/root.rb
aptible-cli-0.16.5 lib/aptible/cli/formatter/root.rb
aptible-cli-0.16.4 lib/aptible/cli/formatter/root.rb
aptible-cli-0.16.3 lib/aptible/cli/formatter/root.rb
aptible-cli-0.16.2 lib/aptible/cli/formatter/root.rb
aptible-cli-0.16.1 lib/aptible/cli/formatter/root.rb
aptible-cli-0.16.0 lib/aptible/cli/formatter/root.rb
aptible-cli-0.15.2 lib/aptible/cli/formatter/root.rb
aptible-cli-0.15.1 lib/aptible/cli/formatter/root.rb
aptible-cli-0.15.0 lib/aptible/cli/formatter/root.rb