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.6.0 lib/junoser/display/enumerable.rb
junoser-0.5.6 lib/junoser/display/enumerable.rb
junoser-0.5.5 lib/junoser/display/enumerable.rb
junoser-0.5.4 lib/junoser/display/enumerable.rb
junoser-0.5.3 lib/junoser/display/enumerable.rb
junoser-0.5.2 lib/junoser/display/enumerable.rb
junoser-0.5.1 lib/junoser/display/enumerable.rb
junoser-0.5.0 lib/junoser/display/enumerable.rb
junoser-0.4.7 lib/junoser/display/enumerable.rb
junoser-0.4.6 lib/junoser/display/enumerable.rb
junoser-0.4.5 lib/junoser/display/enumerable.rb
junoser-0.4.4 lib/junoser/display/enumerable.rb
junoser-0.4.3 lib/junoser/display/enumerable.rb
junoser-0.4.2 lib/junoser/display/enumerable.rb
junoser-0.4.1 lib/junoser/display/enumerable.rb
junoser-0.4.0 lib/junoser/display/enumerable.rb
junoser-0.3.13 lib/junoser/display/enumerable.rb
junoser-0.3.12 lib/junoser/display/enumerable.rb
junoser-0.3.11 lib/junoser/display/enumerable.rb
junoser-0.3.10 lib/junoser/display/enumerable.rb