Class: PointCLI::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/point_cli/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ Command

Returns a new instance of Command.



4
5
6
# File 'lib/point_cli/command.rb', line 4

def initialize(block)
  (class << self;self end).send :define_method, :command, &block
end

Instance Method Details

#call(*args) ⇒ Object



8
9
10
11
12
# File 'lib/point_cli/command.rb', line 8

def call(*args)
  arity = method(:command).arity
  args << nil while args.size < arity
  send :command, *args
end

#display_zone_information(zone) ⇒ Object



24
25
26
# File 'lib/point_cli/command.rb', line 24

def display_zone_information(zone)
  puts "Zone #{zone.inspect}"
end

#dividerObject



54
55
56
# File 'lib/point_cli/command.rb', line 54

def divider
  puts "=" * 80
end

#heading(title) ⇒ Object



49
50
51
52
# File 'lib/point_cli/command.rb', line 49

def heading(title)
  puts "-" * 80
  puts title
end

#select_zone(zone) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/point_cli/command.rb', line 29

def select_zone(zone)
  zones = Point::Zone.find(:all)
  zones = zones.select{|z| z.name.match(/\A#{zone}/) }
  if zones.size == 0
    puts "There are no zones matching the domain you entered"
    Process.exit(1)
  elsif zones.size > 1
    puts "There are multiple zones matching the domain you have posted. Which domain would"
    puts "you like to view?"
    zone_choice = choose do |menu|
      for zone in zones
        menu.choice(zone.name)
      end
    end
    zones.select{|z| z.name == zone_choice}.first
  else
    zones.first
  end
end

#use_hirbObject



14
15
16
17
18
19
20
21
22
# File 'lib/point_cli/command.rb', line 14

def use_hirb
  begin
    require 'hirb'
    extend Hirb::Console
  rescue LoadError
    puts "Hirb is not installed. Install hirb using '[sudo] gem install hirb' to get cool ASCII tables"
    Process.exit(1)
  end      
end