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

Returns:

  • (Boolean)


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

def ascii_only?
  !!(self =~ %r{[^!"#$%&'()*+,\-./:;<=>?@0-9A-Za-z_\[\\\]\{\}^` ~\0\n]})
end

#bytesizeObject

:nodoc:



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

def bytesize # :nodoc:
  length
end

#each_char(&block) ⇒ Object

:nodoc:



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

def each_char(&block) # :nodoc:
  # copied from jcode
  if block_given?
    scan(/./m, &block)
  else
    scan(/./m)
  end
end

#first_lineObject

:nodoc:



12
13
14
# File 'lib/write_xlsx/compatibility.rb', line 12

def first_line
  each_line { |line| return line }
end

#ordObject



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

def ord
  self[0]
end