Class: Orocos::ROS::NameMappings

Inherits:
Object
  • Object
show all
Defined in:
lib/orocos/ros/name_mappings.rb

Overview

Implementation of the ROS name mappings rules

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mappings = Hash.new) ⇒ NameMappings

Returns a new instance of NameMappings



7
8
9
# File 'lib/orocos/ros/name_mappings.rb', line 7

def initialize(mappings = Hash.new)
    @mappings = mappings
end

Instance Attribute Details

#mappingsObject (readonly)

Returns the value of attribute mappings



5
6
7
# File 'lib/orocos/ros/name_mappings.rb', line 5

def mappings
  @mappings
end

Instance Method Details

#apply(string) ⇒ Object



11
12
13
# File 'lib/orocos/ros/name_mappings.rb', line 11

def apply(string)
    mappings[string] || string
end

#to_command_lineObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/orocos/ros/name_mappings.rb', line 15

def to_command_line
    result = []
    mappings.each do |from, to|
        if from =~ /^~/
            from = "_#{from[1..-1]}"
        end
        result << "#{from}:=#{to}"
    end
    result.join(" ")
end