Class: CIM::Array

Inherits:
Type
  • Object
show all
Defined in:
lib/cim/type.rb

Overview

Array represents an array of identical typed value

Constant Summary

Constants inherited from Type

Type::MATCHES, Type::NORMALIZE, Type::TYPES

Instance Attribute Summary collapse

Attributes inherited from Type

#type

Instance Method Summary collapse

Methods inherited from Type

#matches?, normalize, #to_sym

Constructor Details

#initialize(size, type) ⇒ Array

Arrays are initialized by size and type Passing 0 (zero) as the size creates an unlimited array



187
188
189
190
# File 'lib/cim/type.rb', line 187

def initialize size, type
  @size = size
  super type
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



182
183
184
# File 'lib/cim/type.rb', line 182

def size
  @size
end

Instance Method Details

#==(t) ⇒ Object

An array is equal to any other array, regardless of the enclosed type



197
198
199
# File 'lib/cim/type.rb', line 197

def == t
  t == :array
end

#array?Boolean

Returns:

  • (Boolean)


191
192
193
# File 'lib/cim/type.rb', line 191

def array?
  true
end

#to_sObject

returns a string representation of the array type



203
204
205
206
207
208
209
# File 'lib/cim/type.rb', line 203

def to_s
  if @size > 0
	"#{super}[#{@size}]"
  else
	"#{super}[]"
  end
end