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.22.0 lib/aptible/cli/formatter/root.rb
aptible-cli-0.21.0 lib/aptible/cli/formatter/root.rb
aptible-cli-0.20.0 lib/aptible/cli/formatter/root.rb
aptible-cli-0.19.9 lib/aptible/cli/formatter/root.rb
aptible-cli-0.19.7 lib/aptible/cli/formatter/root.rb
aptible-cli-0.19.6 lib/aptible/cli/formatter/root.rb
aptible-cli-0.19.4 lib/aptible/cli/formatter/root.rb
aptible-cli-0.19.3 lib/aptible/cli/formatter/root.rb
aptible-cli-0.19.2 lib/aptible/cli/formatter/root.rb
aptible-cli-0.19.1 lib/aptible/cli/formatter/root.rb
aptible-cli-0.19.0 lib/aptible/cli/formatter/root.rb
aptible-cli-0.18.3 lib/aptible/cli/formatter/root.rb
aptible-cli-0.18.2 lib/aptible/cli/formatter/root.rb
aptible-cli-0.18.1 lib/aptible/cli/formatter/root.rb
aptible-cli-0.18.0 lib/aptible/cli/formatter/root.rb
aptible-cli-0.17.2 lib/aptible/cli/formatter/root.rb
aptible-cli-0.17.1 lib/aptible/cli/formatter/root.rb
aptible-cli-0.17.0 lib/aptible/cli/formatter/root.rb
aptible-cli-0.16.9 lib/aptible/cli/formatter/root.rb
aptible-cli-0.16.8 lib/aptible/cli/formatter/root.rb