Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/news/article.rb

Overview

Add a method to general String class

Constant Summary

SPECIAL =

Special rules for some headers

Hash.new

Instance Method Summary (collapse)

Instance Method Details

- (String) canonical

Change a header name to conform to RFC rules about capitalization

Parameters:

  • name (String)

    name to be changed

Returns:



32
33
34
# File 'lib/news/article.rb', line 32

def canonical
  self.split(%r{([_-])}).map {|i| SPECIAL[i] || i.capitalize }.join('')
end