lib/red_amber/refinements.rb in red_amber-0.3.0 vs lib/red_amber/refinements.rb in red_amber-0.4.0
- old
+ new
@@ -1,7 +1,8 @@
# frozen_string_literal: true
+# Namespace of RedAmber
module RedAmber
# Add additional capabilities to Hash
module RefineHash
refine Hash do
# Convert self to an Arrow::Table
@@ -152,27 +153,31 @@
end
# Add additional capabilities to Array
module RefineArray
refine Array do
- def integers?
+ def integer?
all? { |e| e.is_a?(Integer) } # rubocop:disable Performance/RedundantEqualityComparisonBlock
end
- def booleans?
+ def numeric?
+ all? { |e| e.is_a?(Numeric) } # rubocop:disable Performance/RedundantEqualityComparisonBlock
+ end
+
+ def boolean?
all? { |e| e.is_a?(TrueClass) || e.is_a?(FalseClass) || e.is_a?(NilClass) }
end
- def symbols?
+ def symbol?
all? { |e| e.is_a?(Symbol) } # rubocop:disable Performance/RedundantEqualityComparisonBlock
end
- def strings?
+ def string?
all? { |e| e.is_a?(String) } # rubocop:disable Performance/RedundantEqualityComparisonBlock
end
- def symbols_or_strings?
+ def symbol_or_string?
all? { |e| e.is_a?(Symbol) || e.is_a?(String) }
end
# convert booleans to indices
def booleans_to_indices
@@ -194,6 +199,8 @@
def reject_by_indices(indices)
reject.with_index { |_, i| indices.include?(i) || indices.include?(i - size) }
end
end
end
+
+ private_constant :RefineArray, :RefineArrayLike, :RefineArrowTable, :RefineHash
end