Sha256: a9fb151e965d3b27774ed6941f90a2461986b0ad7f4aabbb9ad63e1b645a184d

Contents?: true

Size: 719 Bytes

Versions: 5

Compression:

Stored size: 719 Bytes

Contents

require_relative 'ip'

class Sapluuna
  module ClassHelpers

    class ::String
      def ip
        IP.new(self).ip
      end
      def acl
        IP.new(self).acl
      end
      def net
        IP.new(self).net
      end
      def cidr
        IP.new(self).cidr
      end
    end

    class ::Array
      def as_ip format_string
        as_method 'ip', format_string
      end

      def as_acl format_string
        as_method 'acl', format_string
      end

      def as_cidr format_string
        as_method 'cidr', format_string
      end

      private

      def as_method method, format_string
        map do |str|
          format_string % str.send(method)
        end.join("\n")
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sapluuna-0.2.0 lib/sapluuna/class_helpers.rb
sapluuna-0.1.7 lib/sapluuna/class_helpers.rb
sapluuna-0.1.6 lib/sapluuna/class_helpers.rb
sapluuna-0.1.5 lib/sapluuna/class_helpers.rb
sapluuna-0.1.4 lib/sapluuna/class_helpers.rb