Class: LadderDrive::LadderDriveConfigTarget
- Inherits:
-
Object
- Object
- LadderDrive::LadderDriveConfigTarget
show all
- Defined in:
- lib/ladder_drive/config_target.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of LadderDriveConfigTarget.
48
49
50
51
|
# File 'lib/ladder_drive/config_target.rb', line 48
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
73
74
75
76
77
78
79
80
81
|
# File 'lib/ladder_drive/config_target.rb', line 73
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
39
40
41
42
43
44
|
# File 'lib/ladder_drive/config_target.rb', line 39
def finalize
proc {
EmuPlcServer.terminate
RaspberrypiPlcServer.terminate
}
end
|
Instance Method Details
#protocol ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/ladder_drive/config_target.rb', line 53
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
|
#uploader ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/ladder_drive/config_target.rb', line 65
def uploader
@uploader ||= begin
u = Uploader.new
u.protocol = self.protocol
u
end
end
|