Class: SAPNW::RFC::Table

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

Overview

RFC Table type Parameters

Instance Attribute Summary

Attributes inherited from Parameter

#decimals, #direction, #len, #name, #typdef, #type, #ulen, #value

Instance Method Summary collapse

Methods inherited from Parameter

#method_missing

Constructor Details

#initialize(*args) ⇒ Table

Returns a new instance of Table.



233
234
235
236
# File 'lib/sapnwrfc/parameters.rb', line 233

def initialize(*args)
  @direction = SAPNW::RFC::TABLES
	super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SAPNW::RFC::Parameter

Instance Method Details

#eachObject

Yields each row of the table to passed Proc



260
261
262
263
264
265
# File 'lib/sapnwrfc/parameters.rb', line 260

def each
  return nil unless @value
	@value.each do |row|
	  yield row
	end
end

#lengthObject

returns the no. of rows currently in the table



239
240
241
# File 'lib/sapnwrfc/parameters.rb', line 239

def length
  return @value.length
end

#value=(val = []) ⇒ Object

the Table parameter.



245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/sapnwrfc/parameters.rb', line 245

def value=(val=[])
     unless val.is_a?(Array)
    raise TypeError, "Must be Array for table value (#{@name}/#{val.class})\n"
	end
	cnt = 0
  val.each do |row|
	  cnt += 1
       unless row.is_a?(Hash)
      raise TypeError, "Must be Hash for table row value (#{@name}/#{cnt}/#{row.class})\n"
	  end
	end
	@value = val
end