Class: Oc::Run::Base

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

Direct Known Subclasses

Domain, Droplets, Images, Info, Regions, Sizes, Ssh

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



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

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

.example(value) ⇒ Object



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

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

.get_object_name(value = nil) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/system/run/base.rb', line 20

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



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

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

.method_added(method) ⇒ Object



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

def self.method_added(method)
return if self == Oc::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
Oc::Run.add({
  :name => name,
  :class => self,
  :method => method,
  :options => options
  })
  @options = nil
end

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



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

def self.option(switches, description=nil, options={})
  meta << {
    :switches => switches,
    :description => description,
    :type => options[:type].nil? ? "String" : options[:type],
    :default => options[:default],
    :optional => options[:optional]
  }
end

.optionsObject



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

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

.summary(value) ⇒ Object



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

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

.syntax(value) ⇒ Object



29
30
31
# File 'lib/system/run/base.rb', line 29

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