### Home Classes Methods

### In Files

- lib/ffi/tools/const_generator.rb

### Parent

Object

### Methods

- ::new
- #converted_value
- #ruby_name
- #to_ruby

### Files

- Makefile
- LICENSE
- compile
- configure
- depcomp
- stamp-vti
- install-sh
- libtool-version
- mdate-sh
- missing

### Class/Module Index

Quicksearch

- FFI
- FFI::AbstractMemory
- FFI::ArrayType
- FFI::AutoPointer
- FFI::AutoPointer::CallableReleaser
- FFI::AutoPointer::DefaultReleaser
- FFI::AutoPointer::Releaser
- FFI::Buffer
- FFI::ConstGenerator
- FFI::ConstGenerator::Constant
- FFI::DataConverter
- FFI::DynamicLibrary
- FFI::DynamicLibrary::Symbol
- FFI::Enum
- FFI::Enums
- FFI::Function
- FFI::FunctionType
- FFI::Generator
- FFI::Generator::Task
- FFI::IO
- FFI::LastError
- FFI::ManagedStruct
- FFI::MemoryPointer
- FFI::NullPointerError
- FFI::Platform
- FFI::PlatformError
- FFI::Pointer
- FFI::StrPtrConverter
- FFI::Struct
- FFI::Struct::ManagedStructConverter
- FFI::StructByReference
- FFI::StructByValue
- FFI::StructGenerator
- FFI::StructGenerator::Field
- FFI::StructLayout
- FFI::StructLayout::Array
- FFI::StructLayout::Enum
- FFI::StructLayout::Field
- FFI::StructLayout::Function
- FFI::StructLayout::InnerStruct
- FFI::StructLayout::Mapped
- FFI::StructLayout::Number
- FFI::StructLayout::Pointer
- FFI::StructLayout::String
- FFI::StructLayoutBuilder
- FFI::TypesGenerator
- FFI::Union
- FFI::VariadicInvoker

No matching classes.

# FFI::ConstGenerator::Constant

This class hold constants for {ConstGenerator}

### Attributes

cast[R]
format[R]
name[R]
value[RW]

### Public Class Methods

new(name, format, cast, ruby_name = nil, converter=nil) click to toggle source

@param [to_s] name @param [String] format a printf format string to print the value out @param [String] cast a C cast for the value @param ruby_name alternate ruby name for {to_ruby} @param [call] converter convert the value from a string to the appropriate

    type for {#to_ruby}.

    # File lib/ffi/tools/const_generator.rb, line 196
    def initialize(name, format, cast, ruby_name = nil, converter=nil)
      @name = name
      @format = format
      @cast = cast
      @ruby_name = ruby_name
      @converter = converter
      @value = nil
    end

### Public Instance Methods

converted_value() click to toggle source

Return constant value (converted if a `converter` was defined). @return constant value.

    # File lib/ffi/tools/const_generator.rb, line 207
    def converted_value
      if @converter
        @converter.call(@value)
      else
        @value
      end
    end

ruby_name() click to toggle source

get constant ruby name @return [String]

    # File lib/ffi/tools/const_generator.rb, line 217
    def ruby_name
      @ruby_name || @name
    end

to_ruby() click to toggle source

Get an evaluable string from constant. @return [String]

    # File lib/ffi/tools/const_generator.rb, line 223
    def to_ruby
      "#{ruby_name} = #{converted_value}"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.