Class: Gdsii::BnfItem
- Inherits:
-
Object
- Object
- Gdsii::BnfItem
- Defined in:
- lib/gdsii/bnf.rb
Overview
Class to hold BNF items which are to be listed in the BnfSpec class. The BnfItem objects are used to indicate the unique BNF key and also whether or not it is optional and whether or not it is multiple.
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#multiple ⇒ Object
readonly
Returns the value of attribute multiple.
-
#optional ⇒ Object
readonly
Returns the value of attribute optional.
Instance Method Summary collapse
-
#initialize(key, optional = false, multiple = false) ⇒ BnfItem
constructor
Create a new BNF item of a given key and specify if it is optional and if there are multiple values.
-
#inspect ⇒ Object
(hide from RDoc) - Add details to inspect.
-
#multiple? ⇒ Boolean
True if this BNF item has multiple values; false if not.
-
#optional? ⇒ Boolean
True if this BNF item is optional; false if not (opposite of #required?).
-
#to_s ⇒ Object
Dump the name for this BNF item.
Constructor Details
#initialize(key, optional = false, multiple = false) ⇒ BnfItem
Create a new BNF item of a given key and specify if it is optional and if there are multiple values. The key is either one of the Gdsii::GRT_* constants or is a class descended from Gdsii::Group. Examples:
BnfItem.new(Property,true,true),
BnfItem.new(GRT_ENDEL)
23 24 25 26 27 |
# File 'lib/gdsii/bnf.rb', line 23 def initialize(key, optional=false, multiple=false) @key = key @optional = optional @multiple = multiple end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
12 13 14 |
# File 'lib/gdsii/bnf.rb', line 12 def key @key end |
#multiple ⇒ Object (readonly)
Returns the value of attribute multiple.
12 13 14 |
# File 'lib/gdsii/bnf.rb', line 12 def multiple @multiple end |
#optional ⇒ Object (readonly)
Returns the value of attribute optional.
12 13 14 |
# File 'lib/gdsii/bnf.rb', line 12 def optional @optional end |
Instance Method Details
#inspect ⇒ Object
(hide from RDoc) - Add details to inspect
47 48 49 |
# File 'lib/gdsii/bnf.rb', line 47 def inspect() # :nodoc: "#<#{self.class}:0x#{sprintf("%x", self.object_id*2)} == #{self.to_s}>" end |
#multiple? ⇒ Boolean
True if this BNF item has multiple values; false if not
37 |
# File 'lib/gdsii/bnf.rb', line 37 def multiple?() @multiple; end |
#optional? ⇒ Boolean
True if this BNF item is optional; false if not (opposite of #required?)
32 |
# File 'lib/gdsii/bnf.rb', line 32 def optional?() @optional; end |
#to_s ⇒ Object
Dump the name for this BNF item
42 |
# File 'lib/gdsii/bnf.rb', line 42 def to_s(); Gdsii::grt_name(@key); end |