Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/wnm_support/core_ext/unicode.rb,
lib/wnm_support/core_ext/to_array.rb,
lib/wnm_support/core_ext/max_words.rb,
lib/wnm_support/core_ext/is_integer.rb
Instance Method Summary collapse
Instance Method Details
#is_integer? ⇒ Boolean
2 3 4 |
# File 'lib/wnm_support/core_ext/is_integer.rb', line 2 def is_integer? self.to_i > 0 && self.to_i.to_s == self end |
#max_words(word_limit = 2, ending = '...') ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/wnm_support/core_ext/max_words.rb', line 2 def max_words(word_limit = 2, ending = '...') words = self.split(/\s/) if words.size > word_limit words[0..(word_limit-1)].join(" ") + ending else self end end |
#to_a ⇒ Object
8 9 10 |
# File 'lib/wnm_support/core_ext/to_array.rb', line 8 def to_a Array.wrap(self) end |