Class: Faker::Measurement

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

Constant Summary collapse

ALL =
"all"
NONE =
"none"

Constants inherited from Base

Base::Letters, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

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

Class Method Details

.height(amount = rand(10)) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/faker/measurement.rb', line 7

def height(amount = rand(10))
  ensure_valid_amount(amount)
  if amount == ALL
    make_plural(fetch('measurement.height'))
  elsif amount == NONE
    fetch('measurement.height')
  else
    "#{amount.to_s} #{check_for_plural(fetch('measurement.height'), amount)}"
  end
end

.length(amount = rand(10)) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/faker/measurement.rb', line 18

def length(amount = rand(10))
  ensure_valid_amount(amount)
  if amount == ALL
    make_plural(fetch('measurement.length'))
  elsif amount == NONE
    fetch('measurement.length')
  else
    "#{amount.to_s} #{check_for_plural(fetch('measurement.length'), amount)}"
  end
end

.metric_height(amount = rand(10)) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/faker/measurement.rb', line 51

def metric_height(amount = rand(10))
  ensure_valid_amount(amount)
  if amount == ALL
    make_plural(fetch('measurement.height'))
  elsif amount == NONE
    fetch('measurement.height')
  else
    "#{amount.to_s} #{check_for_plural(fetch('measurement.height'), amount)}"
  end
end

.metric_length(amount = rand(10)) ⇒ Object



62
63
64
65
66
67
68
69
70
71
# File 'lib/faker/measurement.rb', line 62

def metric_length(amount = rand(10))
  ensure_valid_amount(amount)
  if amount == ALL
    make_plural(fetch('measurement.length'))
  elsif amount == NONE
    fetch('measurement.length')
  else
    "#{amount.to_s} #{check_for_plural(fetch('measurement.length'), amount)}"
  end
end

.metric_volume(amount = rand(10)) ⇒ Object



73
74
75
76
77
78
79
80
81
82
# File 'lib/faker/measurement.rb', line 73

def metric_volume(amount = rand(10))
  ensure_valid_amount(amount)
  if amount == ALL
    make_plural(fetch('measurement.volume'))
  elsif amount == NONE
    fetch('measurement.volume')
  else
    "#{amount.to_s} #{check_for_plural(fetch('measurement.volume'), amount)}"
  end
end

.metric_weight(amount = rand(10)) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'lib/faker/measurement.rb', line 84

def metric_weight(amount = rand(10))
  ensure_valid_amount(amount)
  if amount == ALL
    make_plural(fetch('measurement.weight'))
  elsif amount == NONE
    fetch('measurement.weight')
  else
    "#{amount.to_s} #{check_for_plural(fetch('measurement.weight'), amount)}"
  end
end

.volume(amount = rand(10)) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/faker/measurement.rb', line 29

def volume(amount = rand(10))
  ensure_valid_amount(amount)
  if amount == ALL
    make_plural(fetch('measurement.volume'))
  elsif amount == NONE
    fetch('measurement.volume')
  else
    "#{amount.to_s} #{check_for_plural(fetch('measurement.volume'), amount)}"
  end
end

.weight(amount = rand(10)) ⇒ Object



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

def weight(amount = rand(10))
  ensure_valid_amount(amount)
  if amount == ALL
    make_plural(fetch('measurement.weight'))
  elsif amount == NONE
    fetch('measurement.weight')
  else
    "#{amount.to_s} #{check_for_plural(fetch('measurement.weight'), amount)}"
  end
end