Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/imw/utils/extensions/string.rb

Instance Method Summary collapse

Instance Method Details

#dump(uri) ⇒ Object

Dump this string into the given uri.



35
36
37
# File 'lib/imw/utils/extensions/string.rb', line 35

def dump uri
  IMW.open!(uri).dump(self)
end

#ends_with?(suffix) ⇒ Boolean

Does the string end with the specified suffix (stolen from ActiveSupport::CoreExtensions::String::StartsEndsWith)?

Returns:

  • (Boolean)


5
6
7
8
# File 'lib/imw/utils/extensions/string.rb', line 5

def ends_with?(suffix)
  suffix = suffix.to_s
  self[-suffix.length, suffix.length] == suffix
end

#starts_with?(prefix) ⇒ Boolean

Does the string start with the specified prefix (stolen from ActiveSupport::CoreExtensions::String::StartsEndsWith)?

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/imw/utils/extensions/string.rb', line 12

def starts_with?(prefix)
  prefix = prefix.to_s
  self[0, prefix.length] == prefix
end

#to_handleObject

Returns the handle corresponding to this string as a symbol:

"A possible title of a dataset".handle #=> :a_possible_title_of_a_dataset


30
31
32
# File 'lib/imw/utils/extensions/string.rb', line 30

def to_handle
  self.downcase.underscore.to_sym
end