Class: DMap::Render
- Inherits:
-
Object
- Object
- DMap::Render
- Defined in:
- lib/dmap/core.rb
Overview
Rendering options since command-line is all string
Class Method Summary collapse
Class Method Details
.run(command, value) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# 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 |