Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/write_xlsx/compatibility.rb

Overview

Why would we ever use Ruby 1.8.7 when we can backport with something as simple as this?

copied from prawn. modified by Hideo NAKAMURA

Instance Method Summary collapse

Instance Method Details

#ascii_only?Boolean


40
41
42
# File 'lib/write_xlsx/compatibility.rb', line 40

def ascii_only?
  !!(self =~ /[^!"#\$%&'\(\)\*\+,\-\.\/\:\;<=>\[email protected]_\[\\\]\{\}^` ~\0\n]/)
end

#bytesizeObject

:nodoc:


28
29
30
# File 'lib/write_xlsx/compatibility.rb', line 28

def bytesize # :nodoc:
  self.length
end

#each_charObject

:nodoc:


17
18
19
20
21
22
23
24
# File 'lib/write_xlsx/compatibility.rb', line 17

def each_char #:nodoc:
  # copied from jcode
  if block_given?
    scan(/./m) { |x| yield x }
  else
    scan(/./m)
  end
end

#first_lineObject


10
11
12
# File 'lib/write_xlsx/compatibility.rb', line 10

def first_line
  self.each_line { |line| return line }
end

#ordObject


34
35
36
# File 'lib/write_xlsx/compatibility.rb', line 34

def ord
  self[0]
end