Class: Hotdog::Commands::BaseCommand

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

Direct Known Subclasses

Help, Hosts, Search, Tags

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BaseCommand

Returns a new instance of BaseCommand.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hotdog/commands.rb', line 11

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

Instance Attribute Details

#applicationObject (readonly)

Returns the value of attribute application.



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

def application
  @application
end

#confdirObject (readonly)

Returns the value of attribute confdir.



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

def confdir
  @confdir
end

#expiryObject (readonly)

Returns the value of attribute expiry.



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

def expiry
  @expiry
end

#forceObject (readonly)

Returns the value of attribute force.



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

def force
  @force
end

#formatterObject (readonly)

Returns the value of attribute formatter.



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

def formatter
  @formatter
end

#listingObject (readonly)

Returns the value of attribute listing.



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

def listing
  @listing
end

#loggerObject (readonly)

Returns the value of attribute logger.



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

def logger
  @logger
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#tagsObject (readonly)

Returns the value of attribute tags.



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

def tags
  @tags
end

Instance Method Details

#execute(query, *args) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/hotdog/commands.rb', line 38

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)


48
49
50
# File 'lib/hotdog/commands.rb', line 48

def fixed_string?()
  @fixed_string
end

#run(args = []) ⇒ Object

Raises:

  • (NotImplementedError)


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

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