class SOCMaker::SParameterEntry

This class is used to organize static parameters within SOCMaker::SParameter. This class is derived from Parameter and adds the attribute 'token'.

Attributes

token[RW]

Token, which is replaced during generation by the parameter.

Public Class Methods

new( type, token, optional = {} ) click to toggle source

The constructor expects

# File lib/soc_maker/sparameter.rb, line 234
def initialize( type, token, optional = {} )
  init_with( { 'type' => type,
               'token' => token }.merge( optional ) )

end

Public Instance Methods

==(o) click to toggle source

Equality operator

Calls superclass method SOCMaker::Parameter#==
# File lib/soc_maker/sparameter.rb, line 278
def ==(o)
  o.class == self.class   &&
  o.token  == self.token  &&
  super( o )
end
encode_with( coder ) click to toggle source

Encoder method (to yaml)

coder

An instance of the Psych::Coder to encode this class to a YAML file

Calls superclass method SOCMaker::Parameter#encode_with
# 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 ) click to toggle source

Initialization method (from yaml)

coder

An instance of the Psych::Coder to init this class from a YAML file

Calls superclass method SOCMaker::Parameter#init_with
# 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