Class: Gdsii::BnfItem

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#keyObject (readonly)

Returns the value of attribute key.



12
13
14
# File 'lib/gdsii/bnf.rb', line 12

def key
  @key
end

#multipleObject (readonly)

Returns the value of attribute multiple.



12
13
14
# File 'lib/gdsii/bnf.rb', line 12

def multiple
  @multiple
end

#optionalObject (readonly)

Returns the value of attribute optional.



12
13
14
# File 'lib/gdsii/bnf.rb', line 12

def optional
  @optional
end

Instance Method Details

#inspectObject

(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

Returns:

  • (Boolean)


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?)

Returns:

  • (Boolean)


32
# File 'lib/gdsii/bnf.rb', line 32

def optional?() @optional; end

#to_sObject

Dump the name for this BNF item



42
# File 'lib/gdsii/bnf.rb', line 42

def to_s(); Gdsii::grt_name(@key); end