Class: GLib::Flags

Inherits:
Object
  • Object
show all
Defined in:
glib2/lib/glib2.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

._load(obj) ⇒ Object



239
240
241
# File 'glib2/lib/glib2.rb', line 239

def _load(obj)
  new(Marshal.load(obj))
end

.try_convert(value) ⇒ Object



224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'glib2/lib/glib2.rb', line 224

def try_convert(value)
  case value
  when self
    value
  when Integer, String, Symbol, Array
    begin
      new(value)
    rescue ArgumentError
      nil
    end
  else
    nil
  end
end

Instance Method Details

#_dump(limit) ⇒ Object



244
245
246
# File 'glib2/lib/glib2.rb', line 244

def _dump(limit)
  Marshal.dump(to_i, limit)
end

#inspectObject

FIXME



249
250
251
252
253
254
255
256
257
258
259
# File 'glib2/lib/glib2.rb', line 249

def inspect
  values = self.class.values
  if values.find{|x| x == self }
    body = nick
  else
    a = values.select{|x| self >= x }
    a = a.reject{|x| a.find{|y| y > x } }
    body = a.empty? ? '{}' : a.map{|x| x.nick }.join('|')
  end
  format('#<%s %s>', self.class.inspect, body)
end