Class: Dovado::Utilities Private
- Inherits:
-
Object
- Object
- Dovado::Utilities
- Includes:
- Celluloid
- Defined in:
- lib/dovado/utilities.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Library utilities.
Class Method Summary collapse
-
.array_to_sentence(ary, options = {:words_connector => ', ', :two_words_connector => ' and ', :last_word_connector => ' and '}) ⇒ Object
private
Build a sentence from an array.
-
.name_to_sym(name = nil) ⇒ Symbol
private
Convert a key name to symbol.
Class Method Details
.array_to_sentence(ary, options = {:words_connector => ', ', :two_words_connector => ' and ', :last_word_connector => ' and '}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build a sentence from an array.
Ported from ActiveSupport:
-
File activesupport/lib/active_support/core_ext/array/conversions.rb, line 59
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dovado/utilities.rb', line 27 def self.array_to_sentence(ary, = {:words_connector => ', ', :two_words_connector => ' and ', :last_word_connector => ' and '}) case ary.length when 0 '' when 1 ary[0].to_s.dup when 2 "#{ary[0]}#{[:two_words_connector]}#{ary[1]}" else "#{ary[0...-1].join([:words_connector])}#{[:last_word_connector]}#{ary[-1]}" end end |
.name_to_sym(name = nil) ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert a key name to symbol.
13 14 15 |
# File 'lib/dovado/utilities.rb', line 13 def self.name_to_sym(name=nil) name.downcase.tr(' ', '_').to_sym end |