Class: Hotdog::Commands::BaseCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/hotdog/commands.rb

Direct Known Subclasses

Destroy, Gc, Help, Hosts, Init, Rm, Search, Tags, Update

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, options = {}) ⇒ BaseCommand

Returns a new instance of BaseCommand.



9
10
11
12
13
14
15
16
17
# File 'lib/hotdog/commands.rb', line 9

def initialize(db, options={})
  @db = db
  @formatter = options[:formatter]
  @logger = options[:logger]
  @tags = options[:tags]
  @application = options[:application]
  @options = options
  @dog = Dogapi::Client.new(options[:api_key], options[:application_key])
end

Instance Attribute Details

#applicationObject (readonly)

Returns the value of attribute application.



18
19
20
# File 'lib/hotdog/commands.rb', line 18

def application
  @application
end

#formatterObject (readonly)

Returns the value of attribute formatter.



19
20
21
# File 'lib/hotdog/commands.rb', line 19

def formatter
  @formatter
end

#loggerObject (readonly)

Returns the value of attribute logger.



20
21
22
# File 'lib/hotdog/commands.rb', line 20

def logger
  @logger
end

#optionsObject (readonly)

Returns the value of attribute options.



22
23
24
# File 'lib/hotdog/commands.rb', line 22

def options
  @options
end

#tagsObject (readonly)

Returns the value of attribute tags.



21
22
23
# File 'lib/hotdog/commands.rb', line 21

def tags
  @tags
end

Instance Method Details

#execute(query, *args) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/hotdog/commands.rb', line 28

def execute(query, *args)
  q = query.strip
  if 0 < args.length
    q += " -- VALUES (#{args.map { |arg| Array === arg ? "(#{arg.join(", ")})" : arg.inspect }.join(", ")})"
  end
  logger.debug(q)
  @db.execute(query, args)
end

#run(args = []) ⇒ Object

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/hotdog/commands.rb', line 24

def run(args=[])
  raise(NotImplementedError)
end