Class: CWG::Numbers

Inherits:
Object
  • Object
show all
Defined in:
/Users/martyn/cw/cw_clone/lib/cw/numbers.rb

Overview

class Numbers provides the Number Testing functionality

Instance Method Summary (collapse)

Constructor Details

- (Numbers) initialize(options = {})

Returns a new instance of Numbers



9
10
11
# File '/Users/martyn/cw/cw_clone/lib/cw/numbers.rb', line 9

def initialize(options = {})
  @options = options
end

Instance Method Details

- (Object) generate



25
26
27
28
29
30
# File '/Users/martyn/cw/cw_clone/lib/cw/numbers.rb', line 25

def generate
  @numbers = number_list
  shuffle_numbers_maybe
  reverse_numbers_maybe
  @numbers.split('').join(' ')
end

- (Object) number_list



13
14
15
# File '/Users/martyn/cw/cw_clone/lib/cw/numbers.rb', line 13

def number_list
  '1234567890'
end

- (Object) reverse_numbers_maybe



17
18
19
# File '/Users/martyn/cw/cw_clone/lib/cw/numbers.rb', line 17

def reverse_numbers_maybe
  @numbers.reverse! if @options[:reverse]
end

- (Object) shuffle_numbers_maybe



21
22
23
# File '/Users/martyn/cw/cw_clone/lib/cw/numbers.rb', line 21

def shuffle_numbers_maybe
  @numbers = @numbers.split('').shuffle.join if @options[:shuffle]
end