Class: Escalator::EscalatorConfigTarget
- Inherits:
-
Object
- Object
- Escalator::EscalatorConfigTarget
show all
- Defined in:
- lib/escalator/config_target.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of EscalatorConfigTarget.
46
47
48
49
|
# File 'lib/escalator/config_target.rb', line 46
def initialize options={}
@target_info = options
ObjectSpace.define_finalizer(self, self.class.finalize)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
71
72
73
74
75
76
77
78
79
|
# File 'lib/escalator/config_target.rb', line 71
def method_missing(name, *args)
name = name.to_s unless name.is_a? String
case name.to_s
when /(.*)=$/
@target_info[$1.to_sym] = args.first
else
@target_info[name.to_sym]
end
end
|
Class Method Details
.finalize ⇒ Object
38
39
40
41
42
|
# File 'lib/escalator/config_target.rb', line 38
def finalize
proc {
EmuPlcServer.terminate
}
end
|
Instance Method Details
#protocol ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/escalator/config_target.rb', line 51
def protocol
@protocol ||= begin
p = eval("#{@target_info[:protocol].camelize}.new")
p.host = @target_info[:host] if @target_info[:host]
p.port = @target_info[:port] if @target_info[:port]
p.log_level = @target_info[:log_level] if @target_info[:log_level]
p
rescue
nil
end
end
|
#run ⇒ Object
81
82
83
84
85
86
87
88
89
|
# File 'lib/escalator/config_target.rb', line 81
def run
case self.name
when :emulator
Plc::Emulator::EmuPlcServer.launch
else
end
end
|
#uploader ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/escalator/config_target.rb', line 63
def uploader
@uploader ||= begin
u = Uploader.new
u.protocol = self.protocol
u
end
end
|