class Gdsii::BnfSpec
This class represents the order of a GDSII record grouping using a specific record order in Backus-Naur Form (BNF). It consists of a number of BnfItem objects where the order of the items is important in determining the order in which the GDSII file format should be read or written from/to a file.
Attributes
bnf_items[R]
Public Class Methods
new(*bnf_items)
click to toggle source
Creates a Backus-Naur Form (BNF) grouping consisting of BnfItem objects.
spec = BnfSpec.new( BnfItem.new(GRT_PROPATTR), BnfItem.new(GRT_PROPVALUE) )
# File lib/gdsii/bnf.rb, line 75 def initialize(*bnf_items) @bnf_items = bnf_items end
Public Instance Methods
[](key)
click to toggle source
Shortcut for find_item but will raise an exception if the item key is not part of this BNF.
spec = ... spec.find_item(GRT_PROPATTR) #=> BnfItem ... spec.find_item(GRT_HEADER) #=> raise IndexError ...
# File lib/gdsii/bnf.rb, line 110 def [](key) if (found = find_item(key)) found else raise IndexError, "Cannot find BnfItem of key #{Gdsii::grt_name(key)} in BNF" end end
each() { |bnf_item| ... }
click to toggle source
Loops through each BnfItem in this BnfSpec yielding the BnfItem along the way.
spec.each {|bnf_item| ...}
# File lib/gdsii/bnf.rb, line 85 def each() @bnf_items.each {|bnf_item| yield bnf_item} end
Also aliased as: each_item
find_item(key)
click to toggle source
Finds a BnfItem of a given key in this Bnf object or nil if one is not found.
spec = ... spec.find_item(GRT_PROPATTR) #=> BnfItem ... spec.find_item(GRT_HEADER) #=> nil
# File lib/gdsii/bnf.rb, line 98 def find_item(key) @bnf_items.find {|bnf_item| bnf_item.key == key} end