Module: Ruuuby::Feature::Includable::ArrayF08
- Included in:
- Array
- Defined in:
- lib/ruuuby/class/enumerable/ary.rb
Overview
defines the operations needed to support Feature(f08) that are applied to Class(Array)
Instance Method Summary collapse
-
#end_with?(*ending) ⇒ Boolean
True, if this array ends with the provided elements.
-
#ensure_ending!(*ending) ⇒ Array
This array instance, modified if not ending with provided endings elements.
-
#ensure_start!(*start) ⇒ Array
This array instance, modified if not starting with provided starting elements.
-
#start_with?(*start) ⇒ Boolean
True, if this array starts with the provided elements.
-
#η̂!(normalization_opts) ⇒ Array
TODO: lots of feature-coverage to add.
Instance Method Details
#end_with?(*ending) ⇒ Boolean
Returns true, if this array ends with the provided elements.
18 19 20 21 22 |
# File 'lib/ruuuby/class/enumerable/ary.rb', line 18 def end_with?(*ending) return false if (ending.∅? || ending.𝔠 > self.𝔠) return self.last == ending.₀ if ending.𝔠₁? self.last(ending.𝔠) == ending end |
#ensure_ending!(*ending) ⇒ Array
Returns this array instance, modified if not ending with provided endings elements.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ruuuby/class/enumerable/ary.rb', line 57 def ensure_ending!(*ending) return self if (ending.∅? || self.end_with?(*ending)) return self << ending.₀ if ending.𝔠₁? delta = 0 last_matched = nil while delta <= self.𝔠 && delta <= ending.𝔠 starting_of_end = ending[0..delta] last_matched = starting_of_end if self[self.𝔠₋(delta)..self.𝔠₋] == starting_of_end delta += 1 end if last_matched == nil ending.∀{|element| self << element } else ending[last_matched.𝔠..ending.𝔠₋].∀{|element| self << element} end self end |
#ensure_start!(*start) ⇒ Array
Returns this array instance, modified if not starting with provided starting elements.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ruuuby/class/enumerable/ary.rb', line 36 def ensure_start!(*start) return self if (start.∅? || self.start_with?(*start)) return self >> start.₀ if start.𝔠₁? delta = 0 last_matched = nil while delta <= self.𝔠 && delta <= start.𝔠 ending_of_start = start[start.𝔠₋(delta)..start.𝔠₋] last_matched = ending_of_start if self[0..delta] == ending_of_start delta += 1 end if last_matched == nil start.↩∀{|element| self >> element} else start[0..start.𝔠₋(last_matched.𝔠)].↩∀{|element| self >> element} end self end |
#start_with?(*start) ⇒ Boolean
Returns true, if this array starts with the provided elements.
27 28 29 30 31 |
# File 'lib/ruuuby/class/enumerable/ary.rb', line 27 def start_with?(*start) return false if (start.∅? || start.𝔠 > self.𝔠) return self.first == start.₀ if start.𝔠₁? self.first(start.𝔠) == start end |
#η̂!(normalization_opts) ⇒ Array
TODO: lots of feature-coverage to add
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ruuuby/class/enumerable/ary.rb', line 80 def η̂!(normalization_opts) if ::Math::Space::NumberSpace::NORMALIZERS_ALL_NUMS_W_STR.∋?(normalization_opts) 🛑nums❓(self, normalization_opts) self.∀ₓᵢ do |element, i| if element.num?(normalization_opts) if element.str? if element.to_num? self[i] = element.to_num else raise "normalizer{#{element.to_s}} can't be parsed as a number!" end end end end else raise "normalizer{#{normalization_opts.to_s}} is unknown" end self end |