File: business.rb

package info (click to toggle)
ruby-faker 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,360 kB
  • sloc: ruby: 20,654; makefile: 6; sh: 6
file content (50 lines) | stat: -rw-r--r-- 1,065 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

require 'date'

module Faker
  class Business < Base
    flexible :business

    class << self
      ##
      # Produces a credit card number.
      #
      # @return [String]
      #
      # @example
      #   Faker::Business.credit_card_number #=> "1228-1221-1221-1431"
      #
      # @faker.version 1.2.0
      def credit_card_number
        fetch('business.credit_card_numbers')
      end

      ##
      # Produces a credit card expiration date.
      #
      # @return [Date]
      #
      # @example
      #   Faker::Business.credit_card_expiry_date #=> <Date: 2015-11-11 ((2457338j,0s,0n),+0s,2299161j)>
      #
      # @faker.version 1.2.0
      def credit_card_expiry_date
        ::Date.today + (365 * rand(1..4))
      end

      ##
      # Produces a type of credit card.
      #
      # @return [String]
      #
      # @example
      #   Faker::Business.credit_card_type #=> "visa"
      #
      # @faker.version 1.2.0
      def credit_card_type
        fetch('business.credit_card_types')
      end
    end
  end
end