class GObjectIntrospection::TypeTag
Public Instance Methods
Source
# File lib/gobject-introspection/type-tag.rb, line 37 def description(type_info) method = "description_#{nick}" if respond_to?(method, true) __send__(method, type_info) else nick end end
Source
# File lib/gobject-introspection/type-tag.rb, line 28 def match?(type_info, value) method = "match_#{nick}?" if respond_to?(method, true) __send__(method, type_info, value) else false end end
Source
# File lib/gobject-introspection/type-tag.rb, line 19 def try_convert(type_info, value) method = "try_convert_#{nick}" if respond_to?(method, true) __send__(method, type_info, value) else nil end end
Private Instance Methods
Source
# File lib/gobject-introspection/type-tag.rb, line 179 def description_array_like(type_info) element_type_info = type_info.get_param_type(0) "#{nick}(#{element_type_info.description})" end
Source
# File lib/gobject-introspection/type-tag.rb, line 231 def description_ghash(type_info) key_type = type_info.get_param_type(0) value_type = type_info.get_param_type(1) "#{nick}(#{key_type.description}->#{value_type.description})" end
Source
# File lib/gobject-introspection/type-tag.rb, line 245 def description_interface(type_info) "#{nick}(#{type_info.interface.description})" end
Source
# File lib/gobject-introspection/type-tag.rb, line 184 def get_element_type_info(type_info) type_info.get_param_type(0) end
Source
# File lib/gobject-introspection/type-tag.rb, line 201 def match_array?(type_info, value) case get_element_type_info(type_info).tag when INT8, UINT8 return true if value.is_a?(String) end match_array_like?(type_info, value) end
Source
# File lib/gobject-introspection/type-tag.rb, line 171 def match_array_like?(type_info, value) return false unless value.is_a?(Array) element_type_info = get_element_type_info(type_info) value.all? do |v| v.nil? or element_type_info.match?(v) end end
Also aliased as: match_glist?, match_gslist?
Source
# File lib/gobject-introspection/type-tag.rb, line 58 def match_boolean?(type_info, value) value == true or value == false end
Source
# File lib/gobject-introspection/type-tag.rb, line 154 def match_filename?(type_info, value) value.is_a?(String) end
Source
# File lib/gobject-introspection/type-tag.rb, line 106 def match_float?(type_info, value) value.is_a?(Float) end
Also aliased as: match_double?
Source
# File lib/gobject-introspection/type-tag.rb, line 227 def match_ghash?(type_info, value) value.is_a?(Hash) end
Source
# File lib/gobject-introspection/type-tag.rb, line 116 def match_gtype?(type_info, value) value.is_a?(GLib::Type) end
Source
# File lib/gobject-introspection/type-tag.rb, line 81 def match_integer?(type_info, value) value.is_a?(Integer) end
Also aliased as: match_int8?, match_uint8?, match_int16?, match_uint16?, match_int32?, match_uint32?, match_int64?, match_uint64?
Source
# File lib/gobject-introspection/type-tag.rb, line 241 def match_interface?(type_info, value) type_info.interface.match?(value) end
Source
# File lib/gobject-introspection/type-tag.rb, line 135 def match_utf8?(type_info, value) value.is_a?(String) end
Source
# File lib/gobject-introspection/type-tag.rb, line 188 def try_convert_array(type_info, value) case get_element_type_info(type_info).tag when INT8, UINT8 case value when String return value when GLib::Bytes return value.to_s end end try_convert_array_like(type_info, value) end
Source
# File lib/gobject-introspection/type-tag.rb, line 158 def try_convert_array_like(type_info, value) value = Array.try_convert(value) return nil if value.nil? element_type_info = get_element_type_info(type_info) value.collect do |v| unless v.nil? v = element_type_info.try_convert(v) return nil if v.nil? end v end end
Also aliased as: try_convert_glist, try_convert_gslist
Source
# File lib/gobject-introspection/type-tag.rb, line 47 def try_convert_boolean(type_info, value) case value when true, false value when nil false else nil end end
Source
# File lib/gobject-introspection/type-tag.rb, line 139 def try_convert_filename(type_info, value) case value when String value.encode(GLib::FILENAME_ENCODING) else if value.respond_to?(:to_path) value.to_path.encode(GLib::FILENAME_ENCODING) elsif value.respond_to?(:to_str) value.to_str.encode(GLib::FILENAME_ENCODING) else nil end end end
Source
# File lib/gobject-introspection/type-tag.rb, line 94 def try_convert_float(type_info, value) if value.is_a?(Float) value elsif value.respond_to?(:to_f) # TODO: Should we stop this? value.to_f else nil end end
Also aliased as: try_convert_double
Source
# File lib/gobject-introspection/type-tag.rb, line 218 def try_convert_ghash(type_info, value) case value when Hash value else nil end end
Source
# File lib/gobject-introspection/type-tag.rb, line 112 def try_convert_gtype(type_info, value) GLib::Type.try_convert(value) end
Source
# File lib/gobject-introspection/type-tag.rb, line 62 def try_convert_integer(type_info, value) if value.is_a?(Integer) value elsif value.respond_to?(:to_int) value.to_int else nil end end
Source
# File lib/gobject-introspection/type-tag.rb, line 237 def try_convert_interface(type_info, value) type_info.interface.try_convert(value) end
Source
# File lib/gobject-introspection/type-tag.rb, line 120 def try_convert_utf8(type_info, value) case value when String value.encode(Encoding::UTF_8) when Symbol value.to_s.encode(Encoding::UTF_8) else if value.respond_to?(:to_str) value.to_str.encode(Encoding::UTF_8) else nil end end end