Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/atk/cmd.rb,
lib/atk/remove_indent.rb,
lib/atk/extra_file_utils.rb,
lib/atk/extra_yaml.rb
Overview
easy access to the commandline
Instance Method Summary collapse
-
#-@ ⇒ Object
add a - operator to strings that makes it behave like a system() call but it shows stderr and returns a success value.
-
#/(next_string) ⇒ Object
this is for easy creation of cross-platform filepaths ex: “foldername”/“filename”.
-
#remove_indent ⇒ Object
this is for having docstrings that get their indent removed this is used frequently for multi-line strings and error messages example usage puts <<-HEREDOC.remove_indent This command does such and such.
- #yaml ⇒ Object
Instance Method Details
#-@ ⇒ Object
add a - operator to strings that makes it behave like a system() call but it shows stderr and returns a success value
19 20 21 22 |
# File 'lib/atk/cmd.rb', line 19 def -@ Process.wait(Process.spawn(self)) return $?.success? end |
#/(next_string) ⇒ Object
this is for easy creation of cross-platform filepaths ex: “foldername”/“filename”
16 17 18 19 20 21 22 |
# File 'lib/atk/extra_file_utils.rb', line 16 def /(next_string) if OS.is?("windows") self + "\\" + next_string else File.join(self, next_string) end end |
#remove_indent ⇒ Object
this is for having docstrings that get their indent removed this is used frequently for multi-line strings and error messages example usage puts <<-HEREDOC.remove_indent This command does such and such.
this part is extra indented
HEREDOC
7 8 9 |
# File 'lib/atk/remove_indent.rb', line 7 def remove_indent gsub(/^[ \t]{#{self.match(/^[ \t]*/)[0].length}}/, '') end |
#yaml ⇒ Object
152 153 154 |
# File 'lib/atk/extra_yaml.rb', line 152 def yaml return YAML.load(self) end |