Class: Zone

Inherits:
Object
  • Object
show all
Includes:
CommandProc
Defined in:
lib/zone.rb

Instance Method Summary collapse

Methods included from CommandProc

#help, included

Methods included from ConfigReader

#param

Constructor Details

#initialize(name) ⇒ Zone

Returns a new instance of Zone.



6
7
8
# File 'lib/zone.rb', line 6

def initialize(name)
  @zname = name
end

Instance Method Details

#list(args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/zone.rb', line 10

def list(args)
  if @zname
    puts "unimplemented"
  else
    zones = Route.new.get_all_zones
    lines = []
    lines << ["ZONE", "ID"]
    zones.each {|zone|
      lines << [zone["DomainName"],  zone["ZoneId"].to_s]
      }
    pp_table lines
  end
end

#pp_table(lines) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/zone.rb', line 24

def pp_table(lines)
  ncols = lines[0].length
  maxwidths = Array.new(ncols, 0)
  lines.each { |line|
    line.each_with_index { |col, index|
      maxwidths[index] = [col.length, maxwidths[index]].max
    }
  }
  lines.each { |line|
    line.each_with_index {|col, index|
      printf("%#{maxwidths[index]}s ", col)
      }
    printf("\n")
  }
end