Module: HDLRuby::High::HRef
- Includes:
- Enumerable
- Defined in:
- lib/HDLRuby/hruby_high.rb,
lib/HDLRuby/std/channel.rb
Overview
Enhance references with possibility to act like a writing branch.
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.
-
#write(target, &ruby_block) ⇒ Object
Transmits +target+ to the reference and execute +ruby_block+ if any.
Class Method Details
.included(klass) ⇒ Object
Properties of expressions are also required
2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 |
# File 'lib/HDLRuby/hruby_high.rb', line 2702 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.
2729 2730 2731 2732 2733 2734 2735 2736 |
# File 'lib/HDLRuby/hruby_high.rb', line 2729 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.
2722 2723 2724 |
# File 'lib/HDLRuby/hruby_high.rb', line 2722 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.
2717 2718 2719 |
# File 'lib/HDLRuby/hruby_high.rb', line 2717 def to_ref raise AnyError, "Internal error: to_ref not defined yet for class: #{self.class}" end |
#write(target, &ruby_block) ⇒ Object
Transmits +target+ to the reference and execute +ruby_block+ if any.
895 896 897 898 |
# File 'lib/HDLRuby/std/channel.rb', line 895 def write(target,&ruby_block) self <= target ruby_block.call if ruby_block end |