Class: FFI::ConstGenerator::Constant
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/ffi/tools/const_generator.rb |
Overview
This class hold constants for ::FFI::ConstGenerator
Class Method Summary
Instance Attribute Summary
Instance Method Summary
-
#converted_value ⇒ Object
Return constant value (converted if a
converter
was defined). -
#ruby_name ⇒ String
get constant ruby name.
-
#to_ruby ⇒ String
Get an evaluable string from constant.
Constructor Details
.new(name, format, cast, ruby_name = nil, converter = nil) ⇒ Constant
Instance Attribute Details
#cast (readonly)
[ GitHub ]#format (readonly)
[ GitHub ]#name (readonly)
[ GitHub ]#value (rw)
[ GitHub ]# File 'lib/ffi/tools/const_generator.rb', line 191
attr_accessor :value
Instance Method Details
#converted_value ⇒ Object
Return constant value (converted if a converter
was defined).
# File 'lib/ffi/tools/const_generator.rb', line 210
def converted_value if @converter @converter.call(@value) else @value end end
#ruby_name ⇒ String
get constant ruby name
# File 'lib/ffi/tools/const_generator.rb', line 220
def ruby_name @ruby_name || @name end
#to_ruby ⇒ String
Get an evaluable string from constant.
# File 'lib/ffi/tools/const_generator.rb', line 226
def to_ruby "#{ruby_name} = #{converted_value}" end