Sha256: 744bc8fe6b8c061f824f7571d0173fe78c56845fc3c1e10f115a80576298f24d
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
module DaruLite class Vector module Queryable def empty? @index.empty? end # Check if any one of mentioned values occur in the vector # @param values [Array] values to check for # @return [true, false] returns true if any one of specified values # occur in the vector # @example # dv = DaruLite::Vector.new [1, 2, 3, 4, nil] # dv.include_values? nil, Float::NAN # # => true def include_values?(*values) values.any? { |v| include_with_nan? @data, v } end def any?(&block) @data.data.any?(&block) end def all?(&block) @data.data.all?(&block) end # Returns an array of either none or integer values, indicating the # +regexp+ matching with the given array. # # @param regexp [Regexp] A regular matching expression. For example, +/weeks/+. # # @return [Array] Containing either +nil+ or integer values, according to the match with the given +regexp+ # # @example # dv = DaruLite::Vector.new(['3 days', '5 weeks', '2 weeks']) # dv.match(/weeks/) # # # => [false, true, true] def match(regexp) @data.map { |value| !!(value =~ regexp) } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
daru_lite-0.1.3 | lib/daru_lite/vector/queryable.rb |
daru_lite-0.1.2 | lib/daru_lite/vector/queryable.rb |