Class: Sbuilder::DomainType
- Includes:
- Utils::MyLogger
- Defined in:
- lib/sbuilder/domain_type.rb
Constant Summary collapse
- PROGNAME =
progname for logger default class name
nil- TYPE_DEFS =
{ 'Int' => { :tlaBaseType => true, }, 'BOOLEAN' => { :cardinality => 2, :domain_range => 0..1, :tlaBaseType => true, :map => { 0 => 'FALSE', 1 => 'TRUE', true => 'TRUE', false => 'FALSE', 'TRUE' => 'TRUE', 'FALSE' => 'FALSE', } }, }
Constants included from Utils::MyLogger
Instance Attribute Summary collapse
- #type ⇒ Object readonly
Attributes inherited from Domain
Constructor & configure collapse
-
#initialize(options = {}) ⇒ DomainType
constructor
A new instance of DomainType.
-
#setType(typeIn) ⇒ Object
Set domain
type.
Methods inherited from Domain
#setExtension, #setName, #to_s
Override from base class collapse
-
#cardinality ⇒ Integer
rangeEnd - rangeStart + 1.
-
#domain_entry(i) ⇒ rangeStart
-
-
#domain_range ⇒ Object
Not possible for type domain.
-
#includeNil ⇒ Boolean
Just type, no nils counted here.
-
#render_values ⇒ String
Domain values is the set
type. -
#stringize(val) ⇒ val
No change (because integers should not be wrapped.
-
#tlaBaseType ⇒ Object
It is safe to call
cardinality,domain_values,numberOfElements,render_values, ...
Methods included from Utils::MyLogger
Methods inherited from Domain
#domain_values, #nilValue, #numberOfElements, #render_entry
Constructor Details
#initialize(options = {}) ⇒ DomainType
Returns a new instance of DomainType.
37 38 39 40 41 42 |
# File 'lib/sbuilder/domain_type.rb', line 37 def initialize( = {} ) super( ) @logger = getLogger( PROGNAME, ) @logger.debug( "#{__method__} initialized" ) end |
Instance Attribute Details
#type ⇒ Object (readonly)
30 31 32 |
# File 'lib/sbuilder/domain_type.rb', line 30 def type @type end |
Instance Method Details
#cardinality ⇒ Integer
Returns rangeEnd - rangeStart + 1.
91 92 93 94 95 96 97 98 |
# File 'lib/sbuilder/domain_type.rb', line 91 def cardinality return TYPE_DEFS[type][:cardinality] if TYPE_DEFS[type][:cardinality] msg = " Cardinality not applicable for \#{self.class} type \#{type}\n EOS\n @logger.error \"\#{__method__}, \#{msg}\"\n raise DomainException, msg\nend\n" |
#domain_entry(i) ⇒ rangeStart
Returns + i.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/sbuilder/domain_type.rb', line 102 def domain_entry( i ) if TYPE_DEFS[type][:map] then ret = TYPE_DEFS[type][:map][i] if ret.nil? msg = " Invalid value entry \#{i} for \#{self.class} type \#{type}\n\n Valid values \#{TYPE_DEFS[type][:map].keys.join(',')}\n EOS\n @logger.error \"\#{__method__}, \#{msg}\"\n raise DomainException, msg\n end\n ret\n else\n i\n end\nend\n" |
#domain_range ⇒ Object
Not possible for type domain.
135 136 137 138 139 140 141 142 |
# File 'lib/sbuilder/domain_type.rb', line 135 def domain_range return TYPE_DEFS[type][:domain_range] if TYPE_DEFS[type][:domain_range] msg = " domain_range not applicable for \#{self.class} type \#{type}\n EOS\n @logger.error \"\#{__method__}, \#{msg}\"\n raise DomainException, msg\nend\n" |
#includeNil ⇒ Boolean
Just type, no nils counted here
75 76 77 |
# File 'lib/sbuilder/domain_type.rb', line 75 def includeNil false end |
#render_values ⇒ String
Domain values is the set type
129 130 131 |
# File 'lib/sbuilder/domain_type.rb', line 129 def render_values return type end |
#setType(typeIn) ⇒ Object
Set domain type
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/sbuilder/domain_type.rb', line 48 def setType( typeIn ) if TYPE_DEFS.keys.include?( typeIn ) @type = typeIn else msg=" Invalid type '\#{typeIn}'\n\n Valid types: \#{TYPE_DEFS.keys.join(',')}\n EOS\n @logger.error \"\#{__method__}: \#{msg}\"\n raise DomainException, msg\n end\n \n \nend\n" |
#stringize(val) ⇒ val
Returns no change (because integers should not be wrapped.
121 122 123 |
# File 'lib/sbuilder/domain_type.rb', line 121 def stringize( val ) val end |
#tlaBaseType ⇒ Object
It is safe to call cardinality, domain_values,
numberOfElements, render_values, ...
85 86 87 88 |
# File 'lib/sbuilder/domain_type.rb', line 85 def tlaBaseType return TYPE_DEFS[type][:tlaBaseType] if TYPE_DEFS[type][:tlaBaseType] false end |