Module: HDLRuby::High::HRef
- Includes:
- Enumerable
- Defined in:
- lib/HDLRuby/hruby_high.rb
Overview
Module giving high-level reference properties.
Class Method Summary collapse
-
.included(klass) ⇒ Object
Properties of expressions are also required.
Instance Method Summary collapse
-
#each(&ruby_block) ⇒ Object
Iterate over the elements.
-
#to_event ⇒ Object
Converts to a new event.
-
#to_ref ⇒ Object
Converts to a new reference.
Class Method Details
.included(klass) ⇒ Object
Properties of expressions are also required
2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 |
# File 'lib/HDLRuby/hruby_high.rb', line 2713 def self.included(klass) klass.class_eval do include HExpression include HArrow # Converts to a new expression. def to_expr self.to_ref end end end |
Instance Method Details
#each(&ruby_block) ⇒ Object
Iterate over the elements.
Returns an enumerator if no ruby block is given.
2740 2741 2742 2743 2744 2745 2746 2747 |
# File 'lib/HDLRuby/hruby_high.rb', line 2740 def each(&ruby_block) # No ruby block? Return an enumerator. return to_enum(:each) unless ruby_block # A block? Apply it on each element. self.type.range.heach do |i| yield(self[i]) end end |
#to_event ⇒ Object
Converts to a new event.
2733 2734 2735 |
# File 'lib/HDLRuby/hruby_high.rb', line 2733 def to_event return Event.new(:change,self.to_ref) end |
#to_ref ⇒ Object
Converts to a new reference.
NOTE: to be redefined in case of non-reference class.
2728 2729 2730 |
# File 'lib/HDLRuby/hruby_high.rb', line 2728 def to_ref raise AnyError, "Internal error: to_ref not defined yet for class: #{self.class}" end |