Class: String

Inherits:
Object show all
Defined in:
lib/gri/blank.rb,
lib/gri/msnmp.rb,
lib/gri/mmsgpack.rb

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/gri/blank.rb', line 40

def blank?
  self !~ /[^[:space:]]/
end

#getbyte(idx) ⇒ Object



5
6
7
# File 'lib/gri/msnmp.rb', line 5

def getbyte idx
  self[idx]
end

#slice!(arg1, arg2 = 1) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gri/msnmp.rb', line 11

def slice!(arg1, arg2 = 1)
  return nil if arg2 < 0
  if arg1.class == Fixnum
    rval = self[arg1, arg2]
    len = self.length
    rpos = arg1 + arg2
    rpos += len if arg1 < 0
    rlen = len - rpos
    region_l = self[0...arg1]
    region_r = self[rpos, rlen]
    region_r = '' if region_r == nil
    self.replace(region_l + region_r)
  elsif arg1.class == String
    rval = arg1
    self.gsub!(arg1, "")
  else
    return nil
  end
  rval
end

#to_msgpackObject



34
35
36
# File 'lib/gri/mmsgpack.rb', line 34

def to_msgpack
  "\xdb"+[self.size].pack('N')+self
end