Class: GL::Registry::Group

Inherits:
Token
  • Object
show all
Defined in:
lib/opengl/registry/group.rb

Overview

Describes a logical grouping of enumerated values.

Instance Attribute Summary collapse

Attributes inherited from Token

#comment

Instance Method Summary collapse

Methods inherited from Token

#to_s

Constructor Details

#initialize(node) ⇒ Group

Creates a new instance of the GL::Registry::Group class.

Parameters:

  • node (Ox::Element)

    The XML element defining the instance.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/opengl/registry/group.rb', line 33

def initialize(node)
  super(node)

  @namespace = node[Words::NAMESPACE]
  @name = node[Words::GROUP]
  type = node[Words::TYPE]
  @bitmask = type && type == Words::BITMASK
  @vendor = node[Words::VENDOR]

  first = node[Words::RANGE_START]
  if first
    last = node[Words::RANGE_END]
    @range = Range.new(first.hex, last.hex, false) if last
  end

  @members = []
  node.locate('enum').each do |enum|
    next unless enum.is_a?(Ox::Element)
    @members << Enum.new(enum)
  end
end

Instance Attribute Details

#membersArray<Enum> (readonly)

Returns an array of enum values that are associated with this group.

Returns:

  • (Array<Enum>)

    an array of enum values that are associated with this group.



14
15
16
# File 'lib/opengl/registry/group.rb', line 14

def members
  @members
end

#nameString? (readonly)

Note:

Not all groups are named, and this value may be nil.

Returns the name of this grouping.

Returns:

  • (String?)

    the name of this grouping.



19
20
21
# File 'lib/opengl/registry/group.rb', line 19

def name
  @name
end

#namespaceString (readonly)

Returns the namespace this group belongs within.

Returns:

  • (String)

    the namespace this group belongs within.



10
11
12
# File 'lib/opengl/registry/group.rb', line 10

def namespace
  @namespace
end

#rangeRange? (readonly)

Returns an end-inclusive range of values this group covers.

Returns:

  • (Range?)

    an end-inclusive range of values this group covers.



27
28
29
# File 'lib/opengl/registry/group.rb', line 27

def range
  @range
end

#vendorString? (readonly)

Returns the name of the vendor that defines this value.

Returns:

  • (String?)

    the name of the vendor that defines this value.



23
24
25
# File 'lib/opengl/registry/group.rb', line 23

def vendor
  @vendor
end

Instance Method Details

#bitmask?Boolean

Returns true if group members are flags that can be bitwise OR'ed together, otherwise false.

Returns:

  • (Boolean)

    true if group members are flags that can be bitwise OR'ed together, otherwise false.



57
58
59
# File 'lib/opengl/registry/group.rb', line 57

def bitmask?
  @bitmask
end