Class: Range

Inherits:
Object
  • Object
show all
Defined in:
lib/HDLRuby/hruby_high.rb

Overview

Extends the range class to support to_low

Instance Method Summary collapse

Instance Method Details

#heach(&ruby_block) ⇒ Object

Iterates over the range as hardware.

Returns an enumerator if no ruby block is given.



4694
4695
4696
4697
4698
4699
4700
4701
4702
# File 'lib/HDLRuby/hruby_high.rb', line 4694

def heach(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:heach) unless ruby_block
    # Order the bounds to be able to iterate.
    first,last = self.first, self.last
    first,last = first > last ? [last,first] : [first,last]
    # Iterate.
    (first..last).each(&ruby_block)
end

#to_lowObject

Convert the first and last to HDLRuby::Low



4683
4684
4685
4686
4687
4688
4689
# File 'lib/HDLRuby/hruby_high.rb', line 4683

def to_low
    first = self.first
    first = first.respond_to?(:to_low) ? first.to_low : first
    last = self.last
    last = last.respond_to?(:to_low) ? last.to_low : last
    return (first..last)
end