Class: HDLRuby::High::Std::HEnumerator
- Inherits:
-
Object
- Object
- HDLRuby::High::Std::HEnumerator
- Includes:
- Enumerable, HEnumArg, HEnumerable
- Defined in:
- lib/HDLRuby/std/hruby_enum.rb
Overview
This is the abstract Enumerator class.
Direct Known Subclasses
Instance Method Summary collapse
-
#+(obj) ⇒ Object
Return a new HEnumerator going on iteration over enumerable +obj+.
-
#heach(&ruby_block) ⇒ Object
(also: #each)
Iterate on each element.
Methods included from HEnumArg
#heach_range, #hwith_index, #hwith_object
Methods included from HEnumerable
#call, #h_to_a, #hall?, #hany?, #hchain, #hchunk, #hchunk_while, #hcompact, #hcount, #hcycle, #hdrop, #hdrop_while, #heach_cons, #heach_entry, #heach_nexts, #heach_range, #heach_slice, #heach_with_index, #heach_with_object, #hfind, #hfind_index, #hfirst, #hflat_map, #hgrep, #hgrep_v, #hgroup_by, #hinclude?, #hinject, #hlazy, #hmap, #hmax, #hmax_by, #hmin, #hmin_by, #hminmax, #hminmax_by, #hnone?, #hone?, #hpartition, #hreject, #hreverse_each, #hselect, #hslice_after, #hslice_before, #hslice_when, #hsort, #hsort_by, #hsum, #htake, #htake_while, #htally, #hto_a, #hto_h, #huniq, #hzip
Methods included from Enumerable
Instance Method Details
#+(obj) ⇒ Object
Return a new HEnumerator going on iteration over enumerable +obj+
874 875 876 |
# File 'lib/HDLRuby/std/hruby_enum.rb', line 874 def +(obj) return self.hto_a + obj.hto_a end |
#heach(&ruby_block) ⇒ Object Also known as: each
Iterate on each element.
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 |
# File 'lib/HDLRuby/std/hruby_enum.rb', line 816 def heach(&ruby_block) # No block given, returns self. return self unless ruby_block # Create a namespace. base_block = ruby_block ruby_block = proc do |*args| HDLRuby::High.top_user.sub do base_block.call(*args) end end # Iterate. if self.respond_to?(:[]) then return self.size.times do |i| ruby_block.call(self[i]) end else return self.hto_a.each(&ruby_block) end end |