Sha256: 96acd9c77054f18f8edbd15a9ef9ab37c299ddb66fb4dd03d563d7a6ea29631b

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

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

# Cast an array to an id.
#
class Array

  # Cast the items to date ids.
  #
  #    [" 2000-12-31 ", " 2001-12-31 ", " 2002-12-31 "].to_date_ids
  #    #=> ["2000-12-31", "2001-12-31", "2002-12-13"]
  #
  def to_date_ids
    map{|x| x.to_date_id}
  end

  # Cast the items to stint ids.
  #
  #    ["2000-12-30-2000-12-31", "2001-12-30-2001-12-31", "2002-12-30-2002-12-31".to_stint_ids
  #    #=> ["2000-12-30-2000-12-31", "2001-12-30-2001-12-31", "2002-12-30-2002-12-31"]
  #
  def to_stint_ids
    map{|x| x.to_stint_id}
  end

  # Cast the items to integer ids.
  #
  #    [" 1 ", " 2 ", " 3 "].to_i_ids
  #    #=> [1, 2, 3]
  #
  def to_i_ids
    map{|x| x.to_i_id}
  end

  # Cast the items to string ids.
  #
  #    [" a ", " b ", " c "].to_i_ids
  #    #=> ["a", "b", "c"]
  #
  def to_s_ids
    map{|x| x.to_s_id}
  end

  # Cast the items to string uuids.
  #
  #    [
  #     " 00000000-0000-0000-0000-000000000000 "
  #     " 11111111-1111-1111-1111-111111111111 ",
  #     " 22222222-2222-2222-2222-222222222222 "
  #    ].to_s_uuids
  #    #=> [
  #     "00000000-0000-0000-0000-000000000000"
  #     "11111111-1111-1111-1111-111111111111",
  #     "22222222-2222-2222-2222-222222222222"
  #    ]
  #
  def to_s_uuids
    map{|x| x.to_s_uuid}
  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/array.rb
sixarm_ruby_to_id-1.1.3 lib/sixarm_ruby_to_id/array.rb
sixarm_ruby_to_id-1.1.2 lib/sixarm_ruby_to_id/array.rb
sixarm_ruby_to_id-1.1.1 lib/sixarm_ruby_to_id/array.rb
sixarm_ruby_to_id-1.1.0 lib/sixarm_ruby_to_id/array.rb
sixarm_ruby_to_id-1.0.9 lib/sixarm_ruby_to_id/array.rb