Class: Hole::Run::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/system/run/base.rb

Direct Known Subclasses

Server

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#config=(value) ⇒ Object (writeonly)

Sets the attribute config

Parameters:

  • value

    the value to set the attribute config to.



2
3
4
# File 'lib/system/run/base.rb', line 2

def config=(value)
  @config = value
end

#options=(value) ⇒ Object (writeonly)

Sets the attribute options

Parameters:

  • value

    the value to set the attribute options to.



2
3
4
# File 'lib/system/run/base.rb', line 2

def options=(value)
  @options = value
end

Class Method Details

.description(value) ⇒ Object



36
37
38
# File 'lib/system/run/base.rb', line 36

def self.description(value)
  options[:description] = value
end

.example(value) ⇒ Object



44
45
46
# File 'lib/system/run/base.rb', line 44

def self.example(value)
  options[:example] = value
end

.get_object_name(value = nil) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/system/run/base.rb', line 23

def self.get_object_name(value=nil)
  @object_name ||= begin
    value ||= if self.name && !self.name.empty?
      self.name.split('::').last
    end
    value.to_s.split(/(?=[A-Z])/).join('-').downcase if value
  end
end

.metaObject



60
61
62
# File 'lib/system/run/base.rb', line 60

def self.meta
  options[:meta] ||=[]
end

.method_added(method) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/system/run/base.rb', line 5

def self.method_added(method)
return if self == Hole::Run::Base
return if private_method_defined? method
return if protected_method_defined? method

prefix = self.get_object_name
method_name = method.to_s == 'run' ? nil : method.to_s.gsub('_','-')
name = [prefix, method_name].compact

Hole::Run.add({
  :name => name,
  :class => self,
  :method => method,
  :options => options
  })
  @options = nil
end

.option(switches, description = nil, options = {}) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/system/run/base.rb', line 48

def self.option(switches, description=nil, options={})
  meta << {
    :switches => switches,
    :description => description,
    :type => String
  }
end

.optionsObject



56
57
58
# File 'lib/system/run/base.rb', line 56

def self.options
  @options ||= {}
end

.summary(value) ⇒ Object



40
41
42
# File 'lib/system/run/base.rb', line 40

def self.summary(value)
  options[:summary] = value
end

.syntax(value) ⇒ Object



32
33
34
# File 'lib/system/run/base.rb', line 32

def self.syntax(value)
  options[:syntax] = value
end