Class: String

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

Constant Summary collapse

NEW_LINE =
"\n"

Instance Method Summary collapse

Instance Method Details

#camelcaseObject



6
7
8
# File 'lib/command_builder_generator/string_extensions.rb', line 6

def camelcase
  words.join
end

#first_lineObject



14
15
16
# File 'lib/command_builder_generator/string_extensions.rb', line 14

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

#snakecaseObject



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_lineObject



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