Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/command_builder/code_generator/string_extensions.rb

Constant Summary collapse

NEW_LINE =
"\n"

Instance Method Summary collapse

Instance Method Details

#camelcaseObject



5
6
7
# File 'lib/command_builder/code_generator/string_extensions.rb', line 5

def camelcase
  words.join
end

#first_lineObject



13
14
15
# File 'lib/command_builder/code_generator/string_extensions.rb', line 13

def first_line
  match(/^.*$/)[0]
end

#snakecaseObject



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_lineObject



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