Class: String
- Inherits:
-
Object
- Object
- String
- Includes:
- Diffable, Redmine::CoreExtensions::String::Conversions, Redmine::CoreExtensions::String::Inflections
- Defined in:
- lib/redmine/core_ext/string.rb,
lib/diff.rb,
lib/faster_csv.rb,
app/controllers/repositories_controller.rb,
vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ber.rb,
vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ber.rb,
vendor/plugins/coderay-0.9.2/lib/coderay/scanner.rb,
vendor/plugins/coderay-0.9.2/lib/coderay/helpers/gzip_simple.rb
Overview
String extensions to use the GZip module.
The methods gzip and gunzip provide an even more simple interface to the ZLib:
# create a big string x = 'a' * 1000 # zip it x_gz = x.gzip # test the result puts 'Zipped %d bytes to %d bytes.' % [x.size, x_gz.size] #-> Zipped 1000 bytes to 19 bytes. # unzipping works p x_gz.gunzip == x #-> true
Direct Known Subclasses
Instance Method Summary
-
- (Object) gunzip
Returns the string, unzipped.
-
- (Object) gunzip!
Replaces the string with its unzipped value.
-
- (Object) gzip(level = GZip::DEFAULT_GZIP_LEVEL)
Returns the string, zipped.
-
- (Object) gzip!(*args)
Replaces the string with its zipped value.
-
- (Object) parse_csv(options = Hash.new)
Equivalent to FasterCSV::parse_line(self, options).
- - (Object) read_ber(syntax = nil)
-
- (Object) to_ber(code = 4)
to_ber A universal octet-string is tag number 4, but others are possible depending on the context, so we let the caller give us one.
-
- (Object) to_ber_application_string(code)
to_ber_application_string.
-
- (Object) to_ber_contextspecific(code)
to_ber_contextspecific.
-
- (Object) to_unix
I love this hack.
- - (Object) with_leading_slash
Methods included from Diffable
#diff, #patch, #replacenextlarger, #reverse_hash
Methods included from Redmine::CoreExtensions::String::Conversions
Instance Method Details
- (Object) gunzip
Returns the string, unzipped. See GZip.gunzip
70 71 72 |
# File 'vendor/plugins/coderay-0.9.2/lib/coderay/helpers/gzip_simple.rb', line 70 def gunzip GZip.gunzip self end |
- (Object) gunzip!
Replaces the string with its unzipped value. See GZip.gunzip
75 76 77 |
# File 'vendor/plugins/coderay-0.9.2/lib/coderay/helpers/gzip_simple.rb', line 75 def gunzip! replace gunzip end |
- (Object) gzip(level = GZip::DEFAULT_GZIP_LEVEL)
Returns the string, zipped. level is the gzip compression level, see GZip.gzip.
81 82 83 |
# File 'vendor/plugins/coderay-0.9.2/lib/coderay/helpers/gzip_simple.rb', line 81 def gzip level = GZip::DEFAULT_GZIP_LEVEL GZip.gzip self, level end |
- (Object) gzip!(*args)
Replaces the string with its zipped value. See GZip.gzip.
86 87 88 |
# File 'vendor/plugins/coderay-0.9.2/lib/coderay/helpers/gzip_simple.rb', line 86 def gzip!(*args) replace gzip(*args) end |
- (Object) parse_csv(options = Hash.new)
Equivalent to FasterCSV::parse_line(self, options).
1982 1983 1984 |
# File 'lib/faster_csv.rb', line 1982 def parse_csv( = Hash.new) FasterCSV.parse_line(self, ) end |
- (Object) read_ber(syntax = nil)
160 161 162 |
# File 'vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ber.rb', line 160 def read_ber syntax=nil StringIO.new(self).read_ber(syntax) end |
- (Object) to_ber(code = 4)
to_ber A universal octet-string is tag number 4, but others are possible depending on the context, so we let the caller give us one. The preferred way to do this in user code is via to_ber_application_sring and to_ber_contextspecific.
244 245 246 |
# File 'vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ber.rb', line 244 def to_ber code = 4 [code].pack('C') + length.to_ber_length_encoding + self end |
- (Object) to_ber_application_string(code)
to_ber_application_string
251 252 253 |
# File 'vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ber.rb', line 251 def to_ber_application_string code to_ber( 0x40 + code ) end |
- (Object) to_ber_contextspecific(code)
to_ber_contextspecific
258 259 260 |
# File 'vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ber.rb', line 258 def to_ber_contextspecific code to_ber( 0x80 + code ) end |
- (Object) to_unix
I love this hack. It seems to silence all dos/unix/mac newline problems.
286 287 288 289 290 291 292 |
# File 'vendor/plugins/coderay-0.9.2/lib/coderay/scanner.rb', line 286 def to_unix if index ?\r gsub(/\r\n?/, "\n") else self end end |
- (Object) with_leading_slash
312 313 314 |
# File 'app/controllers/repositories_controller.rb', line 312 def with_leading_slash starts_with?('/') ? self : "/#{self}" end |