Class: NetLinx::SystemFile
- Inherits:
-
Object
- Object
- NetLinx::SystemFile
- Defined in:
- lib/netlinx/workspace/system_file.rb
Overview
A file node in a NetLinx::System.
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#devices ⇒ Object
Array of D:P:S strings that this file maps to.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#system ⇒ Object
Returns the value of attribute system.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#<<(device) ⇒ Object
Add a device that uses this file.
-
#initialize(**kwargs) ⇒ SystemFile
constructor
A new instance of SystemFile.
-
#to_s ⇒ Object
The SystemFile’s name.
-
#to_xml_element ⇒ REXML::Element
An XML element representing this file.
Constructor Details
#initialize(**kwargs) ⇒ SystemFile
Returns a new instance of SystemFile.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/netlinx/workspace/system_file.rb', line 19 def initialize **kwargs @system = kwargs.fetch :system, nil @name = kwargs.fetch :name, '' @path = kwargs.fetch :path, '' @description = kwargs.fetch :description, '' @type = kwargs.fetch :type, :master @devices = [] system_file_element = kwargs.fetch :element, nil parse_xml_element system_file_element if system_file_element end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
9 10 11 |
# File 'lib/netlinx/workspace/system_file.rb', line 9 def description @description end |
#devices ⇒ Object
Array of D:P:S strings that this file maps to.
12 13 14 |
# File 'lib/netlinx/workspace/system_file.rb', line 12 def devices @devices end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/netlinx/workspace/system_file.rb', line 7 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
8 9 10 |
# File 'lib/netlinx/workspace/system_file.rb', line 8 def path @path end |
#system ⇒ Object
Returns the value of attribute system.
6 7 8 |
# File 'lib/netlinx/workspace/system_file.rb', line 6 def system @system end |
#type ⇒ Object
Returns the value of attribute type.
10 11 12 |
# File 'lib/netlinx/workspace/system_file.rb', line 10 def type @type end |
Instance Method Details
#<<(device) ⇒ Object
Add a device that uses this file.
35 36 37 |
# File 'lib/netlinx/workspace/system_file.rb', line 35 def << device devices << device end |
#to_s ⇒ Object
Returns the SystemFile’s name.
40 41 42 |
# File 'lib/netlinx/workspace/system_file.rb', line 40 def to_s @name end |
#to_xml_element ⇒ REXML::Element
Returns an XML element representing this file.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/netlinx/workspace/system_file.rb', line 45 def to_xml_element REXML::Element.new('File').tap do |file| file.attributes['CompileType'] = 'Netlinx' file.attributes['Type'] = type_lookup[type] file.add_element('Identifier').tap { |e| e.text = name } file.add_element('FilePathName').tap { |e| e.text = path } file.add_element('Comments').tap { |e| e.text = description } @devices.each do |dps| file.add_element('DeviceMap').tap do |e| text = dps.include?(':') ? "Custom [#{dps}]" : dps e.attributes['DevAddr'] = text e.add_element('DevName').text = text end end end end |