Sha256: 0e849dfe80414858c2cd455fb1dfea7adf316a1ca3508d243bf8139395b40836
Contents?: true
Size: 533 Bytes
Versions: 19
Compression:
Stored size: 533 Bytes
Contents
#!/usr/bin/env ruby WORDS_REGEX = /\w+/ UPPER_CASE_WORDS = /([A-Z])/ SPACE_PADDING = /^\s+/ STARTS_WITH_UPPERCASE = /\s*[A-Z]/ starts_with_uppercase = false STDIN.each_line do |line| line.chomp! if line =~ STARTS_WITH_UPPERCASE starts_with_uppercase = true end line.gsub!(UPPER_CASE_WORDS, ' \1') padding = line.scan(SPACE_PADDING)[0].to_s words = line.scan(WORDS_REGEX) if starts_with_uppercase padding = padding[1..(padding.size - 1)] end puts padding + words.map { |word| word.downcase } * '_' end
Version data entries
19 entries across 19 versions & 1 rubygems