Class: SOCMaker::SParameterEntry
- Defined in:
- lib/soc_maker/sparameter.rb
Overview
This class is used to organize static parameters within SOCMaker::SParameter. This class is derived from Parameter and adds the attribute ‘token’.
Instance Attribute Summary collapse
-
#token ⇒ Object
Token, which is replaced during generation by the parameter.
Attributes inherited from Parameter
#choice, #default, #description, #editable, #max, #min, #type, #visible
Instance Method Summary collapse
-
#==(o) ⇒ Object
Equality operator.
-
#encode_with(coder) ⇒ Object
Encoder method (to yaml).
-
#init_with(coder) ⇒ Object
Initialization method (from yaml).
-
#initialize(type, token, optional = {}) ⇒ SParameterEntry
constructor
The constructor expects.
Methods included from ERR
#consistence_error, #consistence_error_if, #init_error, #init_error_if, #processing_error, #processing_error_if
Constructor Details
#initialize(type, token, optional = {}) ⇒ SParameterEntry
The constructor expects
234 235 236 237 238 |
# File 'lib/soc_maker/sparameter.rb', line 234 def initialize( type, token, optional = {} ) init_with( { 'type' => type, 'token' => token }.merge( optional ) ) end |
Instance Attribute Details
#token ⇒ Object
Token, which is replaced during generation by the parameter.
231 232 233 |
# File 'lib/soc_maker/sparameter.rb', line 231 def token @token end |
Instance Method Details
#==(o) ⇒ Object
Equality operator
278 279 280 281 282 |
# File 'lib/soc_maker/sparameter.rb', line 278 def ==(o) o.class == self.class && o.token == self.token && super( o ) end |
#encode_with(coder) ⇒ Object
Encoder method (to yaml)
coder
-
An instance of the Psych::Coder to encode this class to a YAML file
245 246 247 248 249 250 |
# File 'lib/soc_maker/sparameter.rb', line 245 def encode_with( coder ) init_error_if !coder.is_a?( Psych::Coder ), 'coder is not given as Psych::Coder' super coder coder[ 'token' ] = @token end |
#init_with(coder) ⇒ Object
Initialization method (from yaml)
coder
-
An instance of the Psych::Coder to init this class from a YAML file
258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/soc_maker/sparameter.rb', line 258 def init_with( coder ) init_error_if !( coder.is_a?( Hash ) || coder.is_a?( Psych::Coder ) ), 'coder is not given as Hash neither as Psych::Coder' super coder init_error 'no token specified', field: token if coder[ 'token' ] == nil @token = coder[ 'token' ] init_error 'token is not a string' if !@token.is_a?( String ) init_error 'token has zero size' if @token.size == 0 end |