Class: Alt::URI::Gen::Base

Inherits:
Object show all
Defined in:
lib/rio/alturi/uri_parts.rb

Direct Known Subclasses

AuthParts, URIParts, URIString, UserInfoParts

Instance Method Summary collapse

Instance Method Details

#_do_esc(str, fld) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/rio/alturi/uri_parts.rb', line 32

def _do_esc(str,fld)
  if str
    str.encode('UTF-8')

    Alt::URI::Escape.escape(str.force_encoding('US-ASCII'),fld) 
  end
end

#_do_unesc(str) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rio/alturi/uri_parts.rb', line 39

def _do_unesc(str)
  if str
    ustr = Alt::URI::Escape.unescape(str)
    ustr.force_encoding('UTF-8')
    if @encoding
      begin
        ustr.encode(@encoding)
      rescue Encoding::UndefinedConversionError
        ustr
      end
    else
      ustr
    end
  end
end

#nil_or(val, dflt = nil) {|val| ... } ⇒ Object

Yields:

  • (val)


54
55
56
57
# File 'lib/rio/alturi/uri_parts.rb', line 54

def nil_or(val,dflt=nil,&block)
  return dflt unless val
  yield val
end