Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext.rb
Constant Summary collapse
- BLANK_RE =
/\A[[:space:]]*\z/
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #delete_surrounding(char) ⇒ Object
- #enquote ⇒ Object
- #indent(spaces = 2) ⇒ Object
- #inline_dcm ⇒ Object
- #to_regexp(ignorecase: false, multiline: false, extended: false) ⇒ Object
- #to_si ⇒ Object
Instance Method Details
#blank? ⇒ Boolean
4 5 6 |
# File 'lib/core_ext.rb', line 4 def blank? empty? || BLANK_RE === self || self == "\u001A" end |
#delete_surrounding(char) ⇒ Object
24 25 26 |
# File 'lib/core_ext.rb', line 24 def delete_surrounding(char) self.delete_prefix(char).delete_suffix(char) end |
#enquote ⇒ Object
16 17 18 |
# File 'lib/core_ext.rb', line 16 def enquote "\"#{to_s}\"" end |
#indent(spaces = 2) ⇒ Object
8 9 10 |
# File 'lib/core_ext.rb', line 8 def indent(spaces = 2) lines.map { |line| " " * spaces + line }.join end |
#inline_dcm ⇒ Object
12 13 14 |
# File 'lib/core_ext.rb', line 12 def inline_dcm "KONSERVIERUNG_FORMAT 2.0\n\n" + self end |
#to_regexp(ignorecase: false, multiline: false, extended: false) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/core_ext.rb', line 28 def to_regexp(ignorecase: false, multiline: false, extended: false) = 0 = | Regexp::EXTENDED if extended = | Regexp::IGNORECASE if ignorecase = | Regexp::MULTILINE if multiline Regexp.new(self, ) end |
#to_si ⇒ Object
20 21 22 |
# File 'lib/core_ext.rb', line 20 def to_si [self].pack("H*").unpack("l>").first end |