Class: Hotdog::Commands::BaseCommand

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

Direct Known Subclasses

Down, Help, Hosts, Search, Tags, Up

Constant Summary collapse

PERSISTENT_DB =
"persistent.db"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application) ⇒ BaseCommand

Returns a new instance of BaseCommand.



13
14
15
16
17
18
# File 'lib/hotdog/commands.rb', line 13

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

Instance Attribute Details

#applicationObject (readonly)

Returns the value of attribute application.



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

def application
  @application
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.



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

def options
  @options
end

Instance Method Details

#execute(query, *args) ⇒ Object



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

def execute(query, *args)
  update_db
  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

#fixed_string?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/hotdog/commands.rb', line 37

def fixed_string?()
  @options[:fixed_string]
end

#run(args = []) ⇒ Object

Raises:

  • (NotImplementedError)


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

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