Module: I2PLookuper::SAMHelper
- Defined in:
- lib/i2plookuper.rb
Class Method Summary collapse
Class Method Details
.parsesamcmd(ans) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/i2plookuper.rb', line 23 def self.parsesamcmd ans ans.chomp! ans += " " f = ans.index " " s = ans.index " ", f + 1 w = ans[f+1...s] args = Hash.new loop do g1 = ans.index "=", s+1 break if g1 == nil g2 = nil if ans[g1+1] == "\"" g2 = ans.index "\"", g1+2 args[ans[s+1..g1-1]] = ans[g1+2..g2-1] else g2 = ans.index " ", g1+1 args[ans[s+1..g1-1]] = ans[g1+1..g2-1] end s = g2 end return [ans[0...f], w, args] end |
.samcmd(fircmd, seccmd = nil, args = {}) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/i2plookuper.rb', line 15 def self.samcmd fircmd, seccmd = nil, args = {} cmd = "#{fircmd}#{seccmd ? " #{seccmd}" : ""}" args.each_pair { |arg, value| cmd << " #{arg}=\"#{value.to_s}\"" } return cmd end |