Class: Array
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#include_value?(v) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/time_point.rb', line 15 def include_value?(v) any? do |iv| case iv when Range || Array v.to_i.in?(iv) else if iv.to_s =~ /^\d+$/ && v.to_s =~ /^\d+$/ iv.to_i == v.to_i else iv.to_s == v.to_s end end end end |
#includes_sequence?(sequence) ⇒ Boolean
5 6 7 8 9 10 11 12 13 |
# File 'lib/time_point.rb', line 5 def includes_sequence?(sequence) first_exists = [] each_index do |i| first_exists << i if self[i] == sequence[0] end first_exists.any? do |i| return i if self[i...(i+sequence.length)] == sequence end end |