class HDLRuby::Properties
A HDLRuby
set of properties
Attributes
owner[R]
The HDLRuby
object owning of the set of properties
Public Class Methods
each_key(&ruby_block)
click to toggle source
Iterator over all the property keys
Returns an enumerator if no ruby block is given.
# File lib/HDLRuby/hruby_decorator.rb, line 221 def self.each_key(&ruby_block) # No ruby block? Return an enumerator. return to_enum(:each_key) unless ruby_block # A ruby block? Apply it on each input signal instance. @@property_keys.each(&ruby_block) end
new(owner)
click to toggle source
Create a new set of properties and attach it to HDLRuby
object owner
.
# File lib/HDLRuby/hruby_decorator.rb, line 158 def initialize(owner) # Attach the owner. @owner = owner # Create the set. @content = {} end
Public Instance Methods
[](key)
click to toggle source
Get a property
# File lib/HDLRuby/hruby_decorator.rb, line 198 def [](key) return @content[key] end
[]=(key,value)
click to toggle source
Add a property
# File lib/HDLRuby/hruby_decorator.rb, line 189 def []=(key,value) @@property_keys << key # Add an entry if not present. @content[key] = [] unless @content.key?(key) # Add the value to the entry. @content[key] << value end
clone()
click to toggle source
Clones the properties: also clone the contents.
# File lib/HDLRuby/hruby_decorator.rb, line 166 def clone result = Properties.new(owner) @contents.each do |k,vals| vals.each { |v| result[k] = v } end return result end
each(&ruby_block)
click to toggle source
Iterate over the properties of the current set.
Returns an enumerator if no ruby block is given.
# File lib/HDLRuby/hruby_decorator.rb, line 211 def each(&ruby_block) # No ruby block? Return an enumerator. return to_enum(:each) unless ruby_block # A ruby block? Apply it on each input signal instance. @content.each(&ruby_block) end
each_with_key(key,&ruby_block)
click to toggle source
Iterate over each value associated with key
.
# File lib/HDLRuby/hruby_decorator.rb, line 203 def each_with_key(key,&ruby_block) return unless @content.key?(key) @content[key].each(&ruby_block) end
key?(key)
click to toggle source
Tells if key
is present.
# File lib/HDLRuby/hruby_decorator.rb, line 184 def key?(key) @content.key?(key) end
merge(prop)
click to toggle source
Create a new set of properties by merging with prop
# File lib/HDLRuby/hruby_decorator.rb, line 175 def merge(prop) result = self.clone prop.each do |k,vals| vals.each { |v| result[k] = v } end return result end