Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/manifestly/utilities.rb

Constant Summary collapse

BLANK_RE =
/\A[[:space:]]*\z/

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/manifestly/utilities.rb', line 23

def blank?
  BLANK_RE === self
end

#is_i?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/manifestly/utilities.rb', line 17

def is_i?
  !!(self =~ /\A[-+]?[0-9]+\z/)
end

#starts_with?(prefix) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/manifestly/utilities.rb', line 27

def starts_with?(prefix)
  prefix.respond_to?(:to_str) && self[0, prefix.length] == prefix
end

#wrap(width = 78) ⇒ Object



31
32
33
# File 'lib/manifestly/utilities.rb', line 31

def wrap(width=78)
  gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n")
end