Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/command_builder_generator/string_extensions.rb
Constant Summary collapse
- NEW_LINE =
"\n"
Instance Method Summary collapse
- #camelcase ⇒ Object
- #first_line ⇒ Object
- #snakecase ⇒ Object
- #split_and_strip(pattern) ⇒ Object
- #strip_first_line ⇒ Object
Instance Method Details
#camelcase ⇒ Object
6 7 8 |
# File 'lib/command_builder_generator/string_extensions.rb', line 6 def camelcase words.join end |
#first_line ⇒ Object
14 15 16 |
# File 'lib/command_builder_generator/string_extensions.rb', line 14 def first_line match(/^.*$/)[0] end |
#snakecase ⇒ Object
10 11 12 |
# File 'lib/command_builder_generator/string_extensions.rb', line 10 def snakecase words.join('_').downcase end |
#split_and_strip(pattern) ⇒ Object
24 25 26 |
# File 'lib/command_builder_generator/string_extensions.rb', line 24 def split_and_strip(pattern) split(pattern).map { |s| s.strip } end |
#strip_first_line ⇒ Object
18 19 20 21 22 |
# File 'lib/command_builder_generator/string_extensions.rb', line 18 def strip_first_line first_line_index = self.index NEW_LINE return '' unless first_line_index self[first_line_index+1..self.length-1] end |