Class: GL::Registry::Enum
Overview
Describes an OpenGL enumeration (constant) value.
Instance Attribute Summary collapse
-
#alias_name ⇒ String?
readonly
An alternative name for the value.
-
#api ⇒ Symbol?
readonly
An API associated with this enumeration value.
-
#groups ⇒ Array<String>
readonly
An array of names of the groups this enumeration is defined within.
-
#name ⇒ String
readonly
The name of the enumeration member.
-
#type ⇒ Symbol
readonly
A hint for the enumeration value type (i.e. GLenum, GLuint, GLuint64, etc).
-
#value ⇒ String
readonly
The value of the enumeration, always numerical, typically in hexadecimal format.
Attributes inherited from Token
Instance Method Summary collapse
-
#initialize(node) ⇒ Enum
constructor
Creates a new instance of the Enum class.
-
#to_i ⇒ Integer
The enumeration's value, as an integer.
Methods inherited from Token
Constructor Details
#initialize(node) ⇒ Enum
Creates a new instance of the GL::Registry::Enum class.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/opengl/registry/enum.rb', line 38 def initialize(node) super(node) # Required @name = node[Words::NAME] @value = node[Words::VALUE] # Optional @alias_name = node[Words::ALIAS] @api = node[Words::API]&.to_sym @groups = node[Words::GROUP]&.split(',') || [] @type = case node[Words::TYPE] when Words::U_LONG then :GLuint when Words::U_LONG_LONG then :GLuint64 else :GLenum end end |
Instance Attribute Details
#alias_name ⇒ String? (readonly)
Returns an alternative name for the value.
20 21 22 |
# File 'lib/opengl/registry/enum.rb', line 20 def alias_name @alias_name end |
#api ⇒ Symbol? (readonly)
Returns an API associated with this enumeration value.
28 29 30 |
# File 'lib/opengl/registry/enum.rb', line 28 def api @api end |
#groups ⇒ Array<String> (readonly)
Returns an array of names of the groups this enumeration is defined within.
32 33 34 |
# File 'lib/opengl/registry/enum.rb', line 32 def groups @groups end |
#name ⇒ String (readonly)
Returns the name of the enumeration member.
12 13 14 |
# File 'lib/opengl/registry/enum.rb', line 12 def name @name end |
#type ⇒ Symbol (readonly)
Returns a hint for the enumeration value type (i.e. GLenum, GLuint, GLuint64, etc).
24 25 26 |
# File 'lib/opengl/registry/enum.rb', line 24 def type @type end |
#value ⇒ String (readonly)
Returns the value of the enumeration, always numerical, typically in hexadecimal format.
16 17 18 |
# File 'lib/opengl/registry/enum.rb', line 16 def value @value end |
Instance Method Details
#to_i ⇒ Integer
Returns the enumeration's value, as an integer.
59 60 61 |
# File 'lib/opengl/registry/enum.rb', line 59 def to_i @value.start_with?('0x') ? @value.hex : @value.to_i end |