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, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, shuffle!, translate, unique, with_locale

Class Method Details

.height(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))

    Specifies the random height value.

Returns:



22
23
24
# File 'lib/faker/default/measurement.rb', line 22

def height(amount: rand(10))
  define_measurement_locale(amount, 'height')
end

.length(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))

    Specifies the random length value.

Returns:



37
38
39
# File 'lib/faker/default/measurement.rb', line 37

def length(amount: rand(10))
  define_measurement_locale(amount, 'length')
end

.metric_height(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))

    Specifies the random height value.

Returns:



82
83
84
# File 'lib/faker/default/measurement.rb', line 82

def metric_height(amount: rand(10))
  define_measurement_locale(amount, 'metric_height')
end

.metric_length(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))

    Specifies the random length value.

Returns:



97
98
99
# File 'lib/faker/default/measurement.rb', line 97

def metric_length(amount: rand(10))
  define_measurement_locale(amount, 'metric_length')
end

.metric_volume(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))

    Specifies the random volume value.

Returns:



112
113
114
# File 'lib/faker/default/measurement.rb', line 112

def metric_volume(amount: rand(10))
  define_measurement_locale(amount, 'metric_volume')
end

.metric_weight(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))

    Specifies the random weight value.

Returns:



127
128
129
# File 'lib/faker/default/measurement.rb', line 127

def metric_weight(amount: rand(10))
  define_measurement_locale(amount, 'metric_weight')
end

.volume(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))

    Specifies the random volume value.

Returns:



52
53
54
# File 'lib/faker/default/measurement.rb', line 52

def volume(amount: rand(10))
  define_measurement_locale(amount, 'volume')
end

.weight(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))

    Specifies the random weight value.

Returns:



67
68
69
# File 'lib/faker/default/measurement.rb', line 67

def weight(amount: rand(10))
  define_measurement_locale(amount, 'weight')
end