Class: FFI::ConstGenerator::Constant
- Inherits:
-
Object
- Object
- FFI::ConstGenerator::Constant
- Defined in:
- lib/ffi/tools/const_generator.rb
Instance Attribute Summary collapse
-
#cast ⇒ Object
readonly
Returns the value of attribute cast.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #converted_value ⇒ Object
-
#initialize(name, format, cast, ruby_name = nil, converter = nil) ⇒ Constant
constructor
A new instance of Constant.
- #ruby_name ⇒ Object
- #to_ruby ⇒ Object
Constructor Details
#initialize(name, format, cast, ruby_name = nil, converter = nil) ⇒ Constant
Returns a new instance of Constant.
150 151 152 153 154 155 156 157 |
# File 'lib/ffi/tools/const_generator.rb', line 150 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 |
Instance Attribute Details
#cast ⇒ Object (readonly)
Returns the value of attribute cast.
147 148 149 |
# File 'lib/ffi/tools/const_generator.rb', line 147 def cast @cast end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
147 148 149 |
# File 'lib/ffi/tools/const_generator.rb', line 147 def format @format end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
147 148 149 |
# File 'lib/ffi/tools/const_generator.rb', line 147 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
148 149 150 |
# File 'lib/ffi/tools/const_generator.rb', line 148 def value @value end |
Instance Method Details
#converted_value ⇒ Object
159 160 161 162 163 164 165 |
# File 'lib/ffi/tools/const_generator.rb', line 159 def converted_value if @converter @converter.call(@value) else @value end end |
#ruby_name ⇒ Object
167 168 169 |
# File 'lib/ffi/tools/const_generator.rb', line 167 def ruby_name @ruby_name || @name end |
#to_ruby ⇒ Object
171 172 173 |
# File 'lib/ffi/tools/const_generator.rb', line 171 def to_ruby "#{ruby_name} = #{converted_value}" end |