Class: LibBin::DataShape

Inherits:
DataRange show all
Defined in:
lib/libbin/data_types.rb,
ext/libbin/libbin_c.c

Overview

Default class used to get the shape of a Structure or of a Structure::Scalar. It maintains a memory of it's members

Instance Attribute Summary collapse

Attributes inherited from DataRange

#range

Instance Method Summary collapse

Methods inherited from DataRange

#first, #last, #size

Constructor Details

#initialize(min, max) ⇒ DataShape #initialize(members) ⇒ DataShape

Returns a new instance of DataShape.

Overloads:

  • #initialize(min, max) ⇒ DataShape

    Create a new shape starting and min and ending at max. This shape has no members.

    Parameters:

    • min (Integer)

      start of the shape

    • max (Integer)

      end of the shape

  • #initialize(members) ⇒ DataShape

    Creates a new shape by reducing the shape of it's memeber. Members can be accessed through #members.

    Parameters:

    • members (DataShape)

      the members composing the shape



87
88
89
90
91
92
# File 'lib/libbin/data_types.rb', line 87

def initialize(*args)
  if args.length == 1
    @members = args[0]
  end
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *arg, &block) ⇒ Object

Add method readers for members



71
72
73
74
# File 'lib/libbin/data_types.rb', line 71

def method_missing(m, *arg, &block)
  return @members[m] if @members && @members[m]
  super
end

Instance Attribute Details

#membersObject (readonly)

Returns the value of attribute members.



68
69
70
# File 'lib/libbin/data_types.rb', line 68

def members
  @members
end