Module: Rviz::Helper
Instance Method Summary collapse
-
#attrs_to_s ⇒ Object
convert attr hash to a string in dot format.
- #quote(str) ⇒ Object
- #set(key, value) ⇒ Object
Instance Method Details
#attrs_to_s ⇒ Object
convert attr hash to a string in dot format
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/rviz.rb', line 4 def attrs_to_s attr_strs = Array.new @attrs.each do |k,v| k = self.quote(k) v = self.quote(v) attr_strs << sprintf('%s=%s', k, v) end attr_strs.join(", ") end |
#quote(str) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/rviz.rb', line 19 def quote str if str.match(/\W/) %Q{"#{str.to_s}"} else str.to_s end end |
#set(key, value) ⇒ Object
15 16 17 |
# File 'lib/rviz.rb', line 15 def set key, value @attrs[key] = value end |