Sha256: 7d6f9b0bc000fac437b446e837491ccb87a702ce8404fdbdbdc35f8ce2a1c264

Contents?: true

Size: 879 Bytes

Versions: 26

Compression:

Stored size: 879 Bytes

Contents

require 'junoser/display/config_store'

module Junoser
  module Display
    module Enumerable
      attr_accessor :in_from, :in_then, :in_group

      def to_enum
        if @hash.size > 1
          "[#{@hash.keys.join(' ')}]"
        else
          @hash.keys.first
        end
      end

      private

      def hash_item_to_s(key, value, str)
        value.in_from = true if key == 'from'
        value.in_then = true if key == 'then'
        value.in_group = true if key =~ /^group /

        if in_from && ['next-header', 'port', 'protocol'].include?(key) ||
            in_then && key == 'origin' ||
            in_group && key == 'type'
          str << Junoser::Display::ConfigStore::OFFSET * @depth << "#{key} #{value.to_enum};\n"
        else
          super
        end
      end
    end
  end
end

Junoser::Display::ConfigStore.prepend(Junoser::Display::Enumerable)

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
junoser-0.3.9 lib/junoser/display/enumerable.rb
junoser-0.3.8 lib/junoser/display/enumerable.rb
junoser-0.3.7 lib/junoser/display/enumerable.rb
junoser-0.3.6 lib/junoser/display/enumerable.rb
junoser-0.3.5 lib/junoser/display/enumerable.rb
junoser-0.3.4 lib/junoser/display/enumerable.rb