Class: GirFFI::Builders::PropertyBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/gir_ffi/builders/property_builder.rb

Overview

Creates property getter and setter code for a given IPropertyInfo.

Instance Method Summary collapse

Constructor Details

#initialize(property_info) ⇒ PropertyBuilder

Returns a new instance of PropertyBuilder.



63
64
65
# File 'lib/gir_ffi/builders/property_builder.rb', line 63

def initialize(property_info)
  @info = property_info
end

Instance Method Details

#buildObject



67
68
69
70
# File 'lib/gir_ffi/builders/property_builder.rb', line 67

def build
  setup_getter
  setup_setter if setting_allowed
end

#container_defines_getter_method?Boolean

Returns:



78
79
80
# File 'lib/gir_ffi/builders/property_builder.rb', line 78

def container_defines_getter_method?
  container_info.find_instance_method getter_name
end

#getter_defObject



86
87
88
# File 'lib/gir_ffi/builders/property_builder.rb', line 86

def getter_def
  PropertyGetterBuilder.new(@info, getter_builder).method_definition
end

#setter_defObject



90
91
92
# File 'lib/gir_ffi/builders/property_builder.rb', line 90

def setter_def
  converting_setter_def
end

#setup_getterObject



72
73
74
75
76
# File 'lib/gir_ffi/builders/property_builder.rb', line 72

def setup_getter
  return if container_defines_getter_method?

  container_class.class_eval getter_def, __FILE__, __LINE__
end

#setup_setterObject



82
83
84
# File 'lib/gir_ffi/builders/property_builder.rb', line 82

def setup_setter
  container_class.class_eval setter_def, __FILE__, __LINE__
end