Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/command_builder/code_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
5 6 7 |
# File 'lib/command_builder/code_generator/string_extensions.rb', line 5 def camelcase words.join end |
#first_line ⇒ Object
13 14 15 |
# File 'lib/command_builder/code_generator/string_extensions.rb', line 13 def first_line match(/^.*$/)[0] end |
#snakecase ⇒ Object
9 10 11 |
# File 'lib/command_builder/code_generator/string_extensions.rb', line 9 def snakecase words.join('_').downcase end |
#split_and_strip(pattern) ⇒ Object
23 24 25 |
# File 'lib/command_builder/code_generator/string_extensions.rb', line 23 def split_and_strip(pattern) split(pattern).map { |s| s.strip } end |
#strip_first_line ⇒ Object
17 18 19 20 21 |
# File 'lib/command_builder/code_generator/string_extensions.rb', line 17 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 |