Class: Faker::Measurement

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/measurement.rb

Constant Summary collapse

ALL =
'all'
NONE =
'none'

Constants inherited from Base

Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

.height(legacy_amount = NOT_GIVEN, amount: rand(10)) ⇒ String

Produces a random height measurement.

Examples:

Faker::Measurement.height #=> "6 inches"
Faker::Measurement.height(amount: 1.4) #=> "1.4 inches"
Faker::Measurement.height(amount: "none") #=> "inch"
Faker::Measurement.height(amount: "all") #=> "inches"

Parameters:

  • amount (Integer) (defaults to: rand(10))

    Speficies the random height value.

Returns:

  • (String)

Available since:

  • 1.7.3


22
23
24
25
26
27
28
# File 'lib/faker/default/measurement.rb', line 22

def height(legacy_amount = NOT_GIVEN, amount: rand(10))
  warn_for_deprecated_arguments do |keywords|
    keywords << :amount if legacy_amount != NOT_GIVEN
  end

  define_measurement_locale(amount, 'height')
end

.length(legacy_amount = NOT_GIVEN, amount: rand(10)) ⇒ String

Produces a random length measurement.

Examples:

Faker::Measurement.length #=> "1 yard"
Faker::Measurement.length(amount: 1.4) #=> "1.4 yards"

Parameters:

  • amount (Integer) (defaults to: rand(10))

    Speficies the random length value.

Returns:

  • (String)

Available since:

  • 1.7.3


41
42
43
44
45
46
47
# File 'lib/faker/default/measurement.rb', line 41

def length(legacy_amount = NOT_GIVEN, amount: rand(10))
  warn_for_deprecated_arguments do |keywords|
    keywords << :amount if legacy_amount != NOT_GIVEN
  end

  define_measurement_locale(amount, 'length')
end

.metric_height(legacy_amount = NOT_GIVEN, amount: rand(10)) ⇒ String

Produces a random metric height measurement.

Examples:

Faker::Measurement.metric_height #=> "2 meters"
Faker::Measurement.metric_height(amount: 1.4) #=> "1.4 meters"

Parameters:

  • amount (Integer) (defaults to: rand(10))

    Speficies the random height value.

Returns:

  • (String)

Available since:

  • 1.7.3


98
99
100
101
102
103
104
# File 'lib/faker/default/measurement.rb', line 98

def metric_height(legacy_amount = NOT_GIVEN, amount: rand(10))
  warn_for_deprecated_arguments do |keywords|
    keywords << :amount if legacy_amount != NOT_GIVEN
  end

  define_measurement_locale(amount, 'metric_height')
end

.metric_length(legacy_amount = NOT_GIVEN, amount: rand(10)) ⇒ String

Produces a random metric length measurement.

Examples:

Faker::Measurement.metric_length #=> "0 decimeters"
Faker::Measurement.metric_length(amount: 1.4) #=> "1.4 decimeters"

Parameters:

  • amount (Integer) (defaults to: rand(10))

    Speficies the random length value.

Returns:

  • (String)

Available since:

  • 1.7.3


117
118
119
120
121
122
123
# File 'lib/faker/default/measurement.rb', line 117

def metric_length(legacy_amount = NOT_GIVEN, amount: rand(10))
  warn_for_deprecated_arguments do |keywords|
    keywords << :amount if legacy_amount != NOT_GIVEN
  end

  define_measurement_locale(amount, 'metric_length')
end

.metric_volume(legacy_amount = NOT_GIVEN, amount: rand(10)) ⇒ String

Produces a random metric volume measurement.

Examples:

Faker::Measurement.metric_volume #=> "1 liter"
Faker::Measurement.metric_volume(amount: 1.4) #=> "1.4 liters"

Parameters:

  • amount (Integer) (defaults to: rand(10))

    Speficies the random volume value.

Returns:

  • (String)

Available since:

  • 1.7.3


136
137
138
139
140
141
142
# File 'lib/faker/default/measurement.rb', line 136

def metric_volume(legacy_amount = NOT_GIVEN, amount: rand(10))
  warn_for_deprecated_arguments do |keywords|
    keywords << :amount if legacy_amount != NOT_GIVEN
  end

  define_measurement_locale(amount, 'metric_volume')
end

.metric_weight(legacy_amount = NOT_GIVEN, amount: rand(10)) ⇒ String

Produces a random metric weight measurement.

Examples:

Faker::Measurement.metric_weight #=> "8 grams"
Faker::Measurement.metric_weight(amount: 1.4) #=> "1.4 grams"

Parameters:

  • amount (Integer) (defaults to: rand(10))

    Speficies the random weight value.

Returns:

  • (String)

Available since:

  • 1.7.3


155
156
157
158
159
160
161
# File 'lib/faker/default/measurement.rb', line 155

def metric_weight(legacy_amount = NOT_GIVEN, amount: rand(10))
  warn_for_deprecated_arguments do |keywords|
    keywords << :amount if legacy_amount != NOT_GIVEN
  end

  define_measurement_locale(amount, 'metric_weight')
end

.volume(legacy_amount = NOT_GIVEN, amount: rand(10)) ⇒ String

Produces a random volume measurement.

Examples:

Faker::Measurement.volume #=> "10 cups"
Faker::Measurement.volume(amount: 1.4) #=> "1.4 cups"

Parameters:

  • amount (Integer) (defaults to: rand(10))

    Speficies the random volume value.

Returns:

  • (String)

Available since:

  • 1.7.3


60
61
62
63
64
65
66
# File 'lib/faker/default/measurement.rb', line 60

def volume(legacy_amount = NOT_GIVEN, amount: rand(10))
  warn_for_deprecated_arguments do |keywords|
    keywords << :amount if legacy_amount != NOT_GIVEN
  end

  define_measurement_locale(amount, 'volume')
end

.weight(legacy_amount = NOT_GIVEN, amount: rand(10)) ⇒ String

Produces a random weight measurement.

Examples:

Faker::Measurement.weight #=> "3 pounds"
Faker::Measurement.weight(amount: 1.4) #=> "1.4 pounds"

Parameters:

  • amount (Integer) (defaults to: rand(10))

    Speficies the random weight value.

Returns:

  • (String)

Available since:

  • 1.7.3


79
80
81
82
83
84
85
# File 'lib/faker/default/measurement.rb', line 79

def weight(legacy_amount = NOT_GIVEN, amount: rand(10))
  warn_for_deprecated_arguments do |keywords|
    keywords << :amount if legacy_amount != NOT_GIVEN
  end

  define_measurement_locale(amount, 'weight')
end