Sha256: 76cef6e61a8f2af30c39b73d04500c71b8d94b0028ba773a8fc20a0251ca20e0

Contents?: true

Size: 619 Bytes

Versions: 6

Compression:

Stored size: 619 Bytes

Contents

# -*- coding: utf-8 -*-

# Cast an object to an id.
#
class Object

  # Cast me to an int id.
  #
  #     Object.new.to_i_ids
  #     #=> 70186724200120
  #
  # Call #object_id.to_i on the object; this is a decent default.
  # Subclasses will override this, e.g. String, Array, Numeric, etc.
  #
  def to_i_id
    object_id.to_i
  end

  # Cast me to a list of int ids.
  #
  #     Object.new.to_i_ids
  #     #=> [70186724200120]
  #
  # Call #object_id.to_i on the object; this is a decent default.
  # Subclasses will override this, e.g. String, Array, Numeric, etc.
  #
  def to_i_ids
    [self.to_i_id]
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sixarm_ruby_to_id-2.0.0 lib/sixarm_ruby_to_id/object.rb
sixarm_ruby_to_id-1.1.3 lib/sixarm_ruby_to_id/object.rb
sixarm_ruby_to_id-1.1.2 lib/sixarm_ruby_to_id/object.rb
sixarm_ruby_to_id-1.1.1 lib/sixarm_ruby_to_id/object.rb
sixarm_ruby_to_id-1.1.0 lib/sixarm_ruby_to_id/object.rb
sixarm_ruby_to_id-1.0.9 lib/sixarm_ruby_to_id/object.rb