module EnvCompat
Constants
- VERSION
Public Class Methods
auto(tag, str)
click to toggle source
# File lib/env_compat.rb, line 5 def auto tag, str if str[/#{tag}_/i] decode str[tag.length.+(1)..-1] else "#{tag.upcase}_#{encode str}" end end
decode(str)
click to toggle source
# File lib/env_compat.rb, line 29 def decode str builder = '' _ = CodeBlock.new str.chars.each do |chr| next _.cycle if chr == '_' if _.in_block? case chr when *mapping.keys builder << mapping[chr] else raise "Invalid input!" end else builder << chr end end builder.upcase end
encode(str)
click to toggle source
# File lib/env_compat.rb, line 13 def encode str builder = '' _ = CodeBlock.new str.chars.each do |chr| case chr when *mapping.values builder = _.toggle(builder) unless _.in_block? builder << mapping.invert[chr] else builder = _.toggle(builder) if _.in_block? builder << chr end end builder.upcase end
Private Class Methods
mapping()
click to toggle source
# File lib/env_compat.rb, line 49 def mapping { 'F' => '/', # Forward Slash 'C' => ':', # Colon 'M' => '-', # Minus 'U' => '_', # Underscore 'D' => '.' # Dot } end