Class: MessagePack::IDL::IR::Message

Inherits:
Type
  • Object
show all
Defined in:
lib/msgpack/idl/ir.rb

Direct Known Subclasses

Exception

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#list_type?, #map_type?, #nullable_type?, #parameterized_type?, #real_type, #void_type?

Constructor Details

#initialize(name, super_class, new_fields) ⇒ Message

Returns a new instance of Message.



260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/msgpack/idl/ir.rb', line 260

def initialize(name, super_class, new_fields)
	@name = name
	@super_class = super_class
	@new_fields = new_fields

	if super_class
		@all_fields = (super_class.all_fields + new_fields).sort_by {|f| f.id }
	else
		@all_fields = new_fields
	end
	@max_id = @all_fields.map {|f| f.id }.max || 0
	@max_required_id = @all_fields.select {|f| f.required? }.map {|f| f.id }.max || 0
end

Instance Attribute Details

#all_fieldsObject (readonly)

Returns the value of attribute all_fields.



275
276
277
# File 'lib/msgpack/idl/ir.rb', line 275

def all_fields
  @all_fields
end

#max_idObject (readonly)

Returns the value of attribute max_id.



275
276
277
# File 'lib/msgpack/idl/ir.rb', line 275

def max_id
  @max_id
end

#max_required_idObject (readonly)

Returns the value of attribute max_required_id.



275
276
277
# File 'lib/msgpack/idl/ir.rb', line 275

def max_required_id
  @max_required_id
end

#nameObject (readonly)

Returns the value of attribute name.



274
275
276
# File 'lib/msgpack/idl/ir.rb', line 274

def name
  @name
end

#new_fieldsObject (readonly)

Returns the value of attribute new_fields.



274
275
276
# File 'lib/msgpack/idl/ir.rb', line 274

def new_fields
  @new_fields
end

#super_classObject (readonly)

Returns the value of attribute super_class.



274
275
276
# File 'lib/msgpack/idl/ir.rb', line 274

def super_class
  @super_class
end

Instance Method Details

#[](id) ⇒ Object



277
278
279
# File 'lib/msgpack/idl/ir.rb', line 277

def [](id)
	@all_fields.find {|f| f.id == id }
end