Class: Array
- Defined in:
- lib/jun/active_support/core_ext/array/access.rb,
lib/jun/active_support/core_ext/array/conversion.rb
Instance Method Summary collapse
- #fifth ⇒ Object
- #fourth ⇒ Object
- #second ⇒ Object
- #second_to_last ⇒ Object
- #third ⇒ Object
- #third_to_last ⇒ Object
- #to_sentence(delimiter: ", ", last_delimiter: "and") ⇒ Object
Instance Method Details
#fifth ⇒ Object
16 17 18 |
# File 'lib/jun/active_support/core_ext/array/access.rb', line 16 def fifth self[4] end |
#fourth ⇒ Object
12 13 14 |
# File 'lib/jun/active_support/core_ext/array/access.rb', line 12 def fourth self[3] end |
#second ⇒ Object
4 5 6 |
# File 'lib/jun/active_support/core_ext/array/access.rb', line 4 def second self[1] end |
#second_to_last ⇒ Object
24 25 26 |
# File 'lib/jun/active_support/core_ext/array/access.rb', line 24 def second_to_last self[-2] end |
#third ⇒ Object
8 9 10 |
# File 'lib/jun/active_support/core_ext/array/access.rb', line 8 def third self[2] end |
#third_to_last ⇒ Object
20 21 22 |
# File 'lib/jun/active_support/core_ext/array/access.rb', line 20 def third_to_last self[-3] end |
#to_sentence(delimiter: ", ", last_delimiter: "and") ⇒ Object
4 5 6 7 8 9 |
# File 'lib/jun/active_support/core_ext/array/conversion.rb', line 4 def to_sentence(delimiter: ", ", last_delimiter: "and") return "" if none? return self.first if one? "#{self[0...-1].join(delimiter)} #{last_delimiter} #{self[-1]}" end |