Class: Space2underscore::Underscore
- Inherits:
-
Object
- Object
- Space2underscore::Underscore
- Defined in:
- lib/space2underscore/underscore.rb
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(sentence) ⇒ Underscore
constructor
A new instance of Underscore.
Constructor Details
#initialize(sentence) ⇒ Underscore
Returns a new instance of Underscore.
5 6 7 |
# File 'lib/space2underscore/underscore.rb', line 5 def initialize(sentence) @sentence = sentence end |
Instance Method Details
#convert ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/space2underscore/underscore.rb', line 9 def convert if @sentence.length == 1 @sentence[0].strip.gsub(/\s/, '_') else @sentence.join('_') end end |