Class: OroGen::ROS::Spec::XML::NodeDescription

Inherits:
Object
  • Object
show all
Defined in:
lib/orogen/ros/spec/launcher.rb

Overview

This class represents the node description which can be extracted from a launch file

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, package, type) ⇒ NodeDescription

Initialize the node description



30
31
32
33
34
35
36
37
38
# File 'lib/orogen/ros/spec/launcher.rb', line 30

def initialize(name, package, type)
    @name = name
    @package = package
    @type = type

    NodeDescription.optional_attr.each do |op, val|
        self.instance_variable_set "@#{op}", val
    end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name



12
13
14
# File 'lib/orogen/ros/spec/launcher.rb', line 12

def name
  @name
end

#packageObject (readonly)

Returns the value of attribute package



10
11
12
# File 'lib/orogen/ros/spec/launcher.rb', line 10

def package
  @package
end

#typeObject (readonly)

Returns the value of attribute type



11
12
13
# File 'lib/orogen/ros/spec/launcher.rb', line 11

def type
  @type
end

Class Method Details

.from_xml_node(node) ⇒ OroGen::ROS::Spec::XML::NodeDescription

Create a node description from a xml node

Returns:



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/orogen/ros/spec/launcher.rb', line 42

def self.from_xml_node(node)
    name = node.attributes["name"].to_s
    package = node.attributes["pkg"].to_s
    type = node.attributes["type"].to_s

    nd = NodeDescription.new(name, package, type)

    NodeDescription.optional_attr.each do |o,_|
        if attr = node.attributes[o.to_s]
            nd.instance_variable_set("@#{o}",attr)
        end
    end
    nd
end

.optional_attrHash

Optional attributes in the ROS launcher specification

Returns:

  • (Hash)

    Hash of optional attributed along with the default value



22
23
24
# File 'lib/orogen/ros/spec/launcher.rb', line 22

def self.optional_attr
    @optional_attr
end

Instance Method Details

#to_sString

String description of this object

Returns:

  • (String)


59
60
61
62
63
64
65
66
# File 'lib/orogen/ros/spec/launcher.rb', line 59

def to_s
    desc = "NodeDescription: name: #{name}, package: #{package}, type: #{type}"
    NodeDescription.optional_attr.each do |o,_|
        val = instance_variable_get("@#{o}")
        desc += ", #{o}: #{val}"
    end
    desc
end