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.
Override from base class collapse
-
#cardinality ⇒ Integer
rangeEnd - rangeStart + 1.
-
#domain_entry(i) ⇒ rangeStart
+ i.
-
#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, #setExtension, #setName, #to_s
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 = <<-EOS Cardinality not applicable for #{self.class} type #{type} EOS @logger.error "#{__method__}, #{msg}" raise DomainException, msg end |
#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 = <<-EOS Invalid value entry #{i} for #{self.class} type #{type} Valid values #{TYPE_DEFS[type][:map].keys.join(',')} EOS @logger.error "#{__method__}, #{msg}" raise DomainException, msg end ret else i end end |
#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 = <<-EOS domain_range not applicable for #{self.class} type #{type} EOS @logger.error "#{__method__}, #{msg}" raise DomainException, msg end |
#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=<<-EOS Invalid type '#{typeIn}' Valid types: #{TYPE_DEFS.keys.join(',')} EOS @logger.error "#{__method__}: #{msg}" raise DomainException, msg end end |
#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 |