Class: Hotdog::Commands::BaseCommand

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

Direct Known Subclasses

Down, Help, Hosts, Search, Tags, Up, Version

Constant Summary collapse

PERSISTENT_DB =
"persistent.db"
MASK_DATABASE =
0xffff0000
MASK_QUERY =
0x0000ffff

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application) ⇒ BaseCommand



21
22
23
24
25
26
27
# File 'lib/hotdog/commands.rb', line 21

def initialize(application)
  @application = application
  @logger = application.options[:logger]
  @options = application.options
  @dog = nil # lazy initialization
  @prepared_statements = {}
end

Instance Attribute Details

#applicationObject (readonly)

Returns the value of attribute application.



28
29
30
# File 'lib/hotdog/commands.rb', line 28

def application
  @application
end

#loggerObject (readonly)

Returns the value of attribute logger.



29
30
31
# File 'lib/hotdog/commands.rb', line 29

def logger
  @logger
end

#optionsObject (readonly)

Returns the value of attribute options.



30
31
32
# File 'lib/hotdog/commands.rb', line 30

def options
  @options
end

Instance Method Details

#define_options(optparse, options = {}) ⇒ Object



53
54
55
# File 'lib/hotdog/commands.rb', line 53

def define_options(optparse, options={})
  # nop
end

#execute(q, args = []) ⇒ Object



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

def execute(q, args=[])
  update_db
  execute_db(@db, q, args)
end

#fixed_string?Boolean



41
42
43
# File 'lib/hotdog/commands.rb', line 41

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

#parse_options(optparse, args = []) ⇒ Object



57
58
59
# File 'lib/hotdog/commands.rb', line 57

def parse_options(optparse, args=[])
  optparse.parse(args)
end

#reload(options = {}) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/hotdog/commands.rb', line 45

def reload(options={})
  if @db
    close_db(@db)
    @db = nil
  end
  update_db(options)
end

#run(args = [], options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/hotdog/commands.rb', line 32

def run(args=[], options={})
  raise(NotImplementedError)
end