Sha256: 94cb4f17a58d3083799b10990873bd0904e374aee4fedb8ecdc93d541613d753

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module JunosConfig
  class Application
    attr_accessor :raw,
                  :config,
                  :name
    
    def initialize(config, raw)
      @config = config
      @raw    = raw
      @name   = raw.match(/^\ {4}application (\S+)\ \{$/)[1]
    end
    
    def to_s
      @name
    end
    
    def list_of_objects
      [self]
    end
    
    def details
      "#{name}: #{raw}"
    end
    
  end

  class ApplicationSet
    attr_accessor :raw,
                  :config,
                  :name,
                  :applications
    
    def initialize(config, raw)
      @config = config
      @raw    = raw
      @name   = raw.match(/^\ {4}application\-set (\S+)\ \{$/)[1]
      @applications = raw.scan(/^(\ {8}application (\S+);)$/).collect do |x|
        config.application(x[1])
      end
    end
    
    def to_s
      @name
    end    
    
    def list_of_objects
      applications
    end
    
  end

end

class String
  
  def list_of_objects
    [self]
  end
  
  def details
    to_s
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
junos-config-0.3.0 lib/junos-config/application.rb