Sha256: 7ae134f1a1789777ce70d1366d67a7a434305d3f0d02cbcabc21ffaec632bbe5
Contents?: true
Size: 735 Bytes
Versions: 2
Compression:
Stored size: 735 Bytes
Contents
# # File:: ArrayComparisons.rb # Author:: wkm # Copyright:: 2009 # License:: GPL # # Adds methods to Array for comparing with other arrays # class Array # gives true if self ends with the given array # # [1, 2, 3].ends_with? [2, 3] # ==> true # [1, 2, 3].ends_with? [] # ==> true # [1, 2, 3].ends_with? [1, 2, 3] # ==> true # [1, 2, 3].ends_with? [1, 2] # ==> false def ends_with?(other) # if the supposed 'ending' is longer, it can't be an ending if length < other.length return false end index = -1 while -index <= other.length and -index <= length if other[index] != self[index] return false end index -= 1 end return true end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sitefuel-0.0.0b | lib/sitefuel/extensions/ArrayComparisons.rb |
sitefuel-0.0.0a | lib/sitefuel/extensions/ArrayComparisons.rb |