Class: SAPNW::RFC::Parameter

Inherits:
Parameters::Base show all
Defined in:
lib/sapnwrfc/parameters.rb

Overview

Base class for all Parameter types

Direct Known Subclasses

Changing, Export, Import, Table

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*parms) ⇒ Parameter

constructor called only from the SAPNW::RFC::Connector#discover process def initialize(funcdesc, name, type, len, ulen, decimals)



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/sapnwrfc/parameters.rb', line 90

def initialize(*parms)
  parms = parms.first if parms.class == Array and parms.first.class == Hash
  case parms
    when Array
      # this way happens when the interface of the parameter has been discover()ed
      funcdesc, name, type, len, ulen, decimals, typedef = parms
    when Hash
      # This way happens when a parameter is being manually constructed
      raise "Missing parameter :name => #{parms.inspect}\n" unless parms.has_key?(:name)
      raise "Missing parameter :type => #{parms.inspect}\n" unless parms.has_key?(:type)
      case parms[:type]
        when SAPNW::RFC::CHAR, SAPNW::RFC::DATE, SAPNW::RFC::BCD, SAPNW::RFC::TIME, SAPNW::RFC::BYTE, SAPNW::RFC::TABLE, SAPNW::RFC::NUM, SAPNW::RFC::FLOAT, SAPNW::RFC::INT, SAPNW::RFC::INT2, SAPNW::RFC::INT1, SAPNW::RFC::NULL, SAPNW::RFC::STRUCTURE, SAPNW::RFC::DECF16, SAPNW::RFC::DECF34, SAPNW::RFC::XMLDATA, SAPNW::RFC::STRING, SAPNW::RFC::XSTRING, SAPNW::RFC::EXCEPTION
        else
          if parms[:type].class == SAPNW::RFC::Type
            parms[:typedef] = parms[:type]
            parms[:type] = parms[:typedef].type
            raise "Parameter type (#{self.class}) does not match Type type (#{parms[:typedef].inspect})\n" if self.class == SAPNW::RFC::Table and parms[:type] != SAPNW::RFC::TABLE
          else
            raise "Invalid SAPNW::RFC* type supplied (#{parms[:type]})\n"
          end
      end
      funcdesc = nil
      len = 0
      ulen = 0
      decimals = 0
      name = parms[:name]
      type = parms[:type]
      typedef = parms[:typedef] if parms.has_key?(:typedef)
      len = parms[:len] if parms.has_key?(:len)
      ulen = parms[:ulen] if parms.has_key?(:ulen)
      decimals = parms[:decimals] if parms.has_key?(:decimals)
    else
      raise "invalid parameters: #{parms.inspect}\n"
  end
  @function_descriptor = funcdesc
  @name = name
  @type = type
  @typedef = typedef
  @len = len
  @ulen = ulen
  @decimals = decimals
  @value = nil
  #$stderr.print "initilised parameter(#{@name}): #{self.inspect}\n"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(methid, *rest, &block) ⇒ Object

method_missing is used to pass on any method call to a parameter to the underlying native Ruby data type



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/sapnwrfc/parameters.rb', line 137

def method_missing(methid, *rest, &block)
  meth = methid.id2name
  #$stderr.print "method_missing: #{meth}\n"
  #$stderr.print "parameters: #{@parameters.keys.inspect}\n"
  if block
    @value.send(meth, &block)
  else
    #$stderr.print "Export method_missing - no block: #{meth}\n"
    @value.send(meth, *rest)
  end
end

Instance Attribute Details

#decimalsObject (readonly)

Returns the value of attribute decimals



86
87
88
# File 'lib/sapnwrfc/parameters.rb', line 86

def decimals
  @decimals
end

#directionObject (readonly)

Returns the value of attribute direction



86
87
88
# File 'lib/sapnwrfc/parameters.rb', line 86

def direction
  @direction
end

#lenObject (readonly)

Returns the value of attribute len



86
87
88
# File 'lib/sapnwrfc/parameters.rb', line 86

def len
  @len
end

#nameObject (readonly)

Returns the value of attribute name



86
87
88
# File 'lib/sapnwrfc/parameters.rb', line 86

def name
  @name
end

#typdefObject (readonly)

Returns the value of attribute typdef



86
87
88
# File 'lib/sapnwrfc/parameters.rb', line 86

def typdef
  @typdef
end

#typeObject (readonly)

Returns the value of attribute type



86
87
88
# File 'lib/sapnwrfc/parameters.rb', line 86

def type
  @type
end

#ulenObject (readonly)

Returns the value of attribute ulen



86
87
88
# File 'lib/sapnwrfc/parameters.rb', line 86

def ulen
  @ulen
end

#valueObject

Returns the value of attribute value



86
87
88
# File 'lib/sapnwrfc/parameters.rb', line 86

def value
  @value
end