Class: Hotdog::Commands::BaseCommand

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

Direct Known Subclasses

Down, Help, Hosts, Search, Tag, Tags, Untag, 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

Returns a new instance of BaseCommand.



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

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

Instance Attribute Details

#applicationObject (readonly)

Returns the value of attribute application.



26
27
28
# File 'lib/hotdog/commands.rb', line 26

def application
  @application
end

#loggerObject (readonly)

Returns the value of attribute logger.



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

def logger
  @logger
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

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



51
52
53
# File 'lib/hotdog/commands.rb', line 51

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

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



34
35
36
37
# File 'lib/hotdog/commands.rb', line 34

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

#fixed_string?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/hotdog/commands.rb', line 39

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

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



55
56
57
# File 'lib/hotdog/commands.rb', line 55

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

#reload(options = {}) ⇒ Object



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

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

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

Raises:

  • (NotImplementedError)


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

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