module RIMS::Protocol
Constants
- FetchBody
- IO_DATA_DUMP
Public Class Methods
body(symbol: nil, option: nil, section: nil, section_list: nil, partial_origin: nil, partial_size: nil)
click to toggle source
# File lib/rims/protocol.rb, line 89 def body(symbol: nil, option: nil, section: nil, section_list: nil, partial_origin: nil, partial_size: nil) FetchBody.new(symbol, option, section, section_list, partial_origin, partial_size) end
compile_wildcard(pattern)
click to toggle source
# File lib/rims/protocol.rb, line 45 def compile_wildcard(pattern) src = '\A' src << pattern.gsub(/.*?[*%]/) {|s| Regexp.quote(s[0..-2]) + '.*' } src << Regexp.quote($') if $' src << '\z' Regexp.compile(src) end
decode_base64(base64_txt)
click to toggle source
# File lib/rims/protocol.rb, line 75 def decode_base64(base64_txt) base64_txt.unpack('m')[0] end
encode_base64(plain_txt)
click to toggle source
# File lib/rims/protocol.rb, line 70 def encode_base64(plain_txt) [ plain_txt ].pack('m').each_line.map{|line| line.strip }.join('') end
io_data_log(str)
click to toggle source
# File lib/rims/protocol.rb, line 56 def io_data_log(str) s = '<' s << str.encoding.to_s if (str.ascii_only?) then s << ':ascii_only' end if (IO_DATA_DUMP) then s << '> ' << str.inspect else s << '> ' << str.bytesize.to_s << ' octets' end end
quote(s)
click to toggle source
# File lib/rims/protocol.rb, line 34 def quote(s) qs = ''.encode(s.encoding) case (s) when /"/, /\n/ qs << '{' << s.bytesize.to_s << "}\r\n" << s else qs << '"' << s << '"' end end
Private Instance Methods
body(symbol: nil, option: nil, section: nil, section_list: nil, partial_origin: nil, partial_size: nil)
click to toggle source
# File lib/rims/protocol.rb, line 89 def body(symbol: nil, option: nil, section: nil, section_list: nil, partial_origin: nil, partial_size: nil) FetchBody.new(symbol, option, section, section_list, partial_origin, partial_size) end
compile_wildcard(pattern)
click to toggle source
# File lib/rims/protocol.rb, line 45 def compile_wildcard(pattern) src = '\A' src << pattern.gsub(/.*?[*%]/) {|s| Regexp.quote(s[0..-2]) + '.*' } src << Regexp.quote($') if $' src << '\z' Regexp.compile(src) end
decode_base64(base64_txt)
click to toggle source
# File lib/rims/protocol.rb, line 75 def decode_base64(base64_txt) base64_txt.unpack('m')[0] end
encode_base64(plain_txt)
click to toggle source
# File lib/rims/protocol.rb, line 70 def encode_base64(plain_txt) [ plain_txt ].pack('m').each_line.map{|line| line.strip }.join('') end
io_data_log(str)
click to toggle source
# File lib/rims/protocol.rb, line 56 def io_data_log(str) s = '<' s << str.encoding.to_s if (str.ascii_only?) then s << ':ascii_only' end if (IO_DATA_DUMP) then s << '> ' << str.inspect else s << '> ' << str.bytesize.to_s << ' octets' end end
quote(s)
click to toggle source
# File lib/rims/protocol.rb, line 34 def quote(s) qs = ''.encode(s.encoding) case (s) when /"/, /\n/ qs << '{' << s.bytesize.to_s << "}\r\n" << s else qs << '"' << s << '"' end end