class DMap::Render
Rendering options since command-line is all string
Public Class Methods
run(command, value)
click to toggle source
# File lib/dmap/core.rb, line 54 def self.run(command, value) value = Hash[value.class.name, value] unless value.is_a?(Hash) if command.match(/^:/).nil? command = ':' + command end value.each do |key, val| next if val.nil? temp = val.to_s.split(' ') match = val.match(/^\[(.*?)\]$/) if val.is_a? String if temp.length > 1 and match.class.name != "MatchData" val = '"' + temp.join(' ').strip + '"' end if val.class.name == "Array" val.flatten! val = '[' + val.join(', ').to_s + ']' end next if val.nil? case command when ":within" temp = val.split('..') [':' + command, Range.new(temp[0], temp[1])] else [command.to_s, val] end end end