Class: String

Inherits:
Object show all
Defined in:
vendor/bundler/ruby/2.6.0/bundler/gems/sxp.rb-a6201a87d980/lib/sxp/writer.rb,
vendor/bundler/ruby/2.6.0/bundler/gems/rdf-rdfa-74b60100bc6a/lib/rdf/rdfa/patches/string_hacks.rb,
vendor/bundler/ruby/2.6.0/bundler/gems/rdf-7506695c9b4f/lib/rdf/extensions.rb

Overview

Extensions for Ruby's String class.

Instance Method Summary collapse

Instance Method Details

#align_leftObject

Trim beginning of each line by the amount of indentation in the first line



3
4
5
6
7
8
# File 'vendor/bundler/ruby/2.6.0/bundler/gems/rdf-rdfa-74b60100bc6a/lib/rdf/rdfa/patches/string_hacks.rb', line 3

def align_left
  str = self.sub(/^\s*$/, '')  # Remove leading newline
  str = str[1..-1] if str[0,1] == "\n"
  ws = str.match(/^(\s*)\S/m) ? $1 : ''
  str.gsub(/^#{ws}/m, '')
end

#match?(*args) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'vendor/bundler/ruby/2.6.0/bundler/gems/rdf-7506695c9b4f/lib/rdf/extensions.rb', line 18

def match?(*args)
  !match(*args).nil?
end

#to_sxpString

Returns the SXP representation of this object.

Returns:



60
61
62
# File 'vendor/bundler/ruby/2.6.0/bundler/gems/sxp.rb-a6201a87d980/lib/sxp/writer.rb', line 60

def to_sxp
  inspect
end