class Postman::URL
Public Class Methods
new(url)
click to toggle source
# File lib/postman-ruby.rb, line 8 def initialize(url) # @raw # @auth # @host # @path # @query # @variable if url.class == String url = { 'raw' => url, 'auth' => {}, 'host' => [], 'path' => [], 'variable' => {}, } end @raw = url url.each do |k,v| instance_variable_set("@#{k}", v) self.class.send(:attr_reader, k.to_sym) end if !@variable.nil? && !@variable.empty? var = {} @variable.each do |v| var[v['id']] = v['value'] end @variable = var end end
Public Instance Methods
reset_var(vars)
click to toggle source
# File lib/postman-ruby.rb, line 43 def reset_var(vars) @variable = vars end
set_var(vars)
click to toggle source
# File lib/postman-ruby.rb, line 39 def set_var(vars) vars.each { |k, v| @variable[k] = v } end
to_s()
click to toggle source
# File lib/postman-ruby.rb, line 47 def to_s interpolate end
Private Instance Methods
interpolate()
click to toggle source
# File lib/postman-ruby.rb, line 53 def interpolate url = @raw vars = @raw.scan(/:([A-Za-z\-_]+)(?:\/|$)/).flatten vars.each do |v| url = url.gsub(':'+v, @variable[v]) end url end