Class: Alfabet

Inherits:
Object
  • Object
show all
Defined in:
lib/freshmind/alfabet.rb

Constant Summary collapse

LETTERS =
{
  ru: ('А'..'Я').to_a - %w[Ъ Ь] + %w[Ё],
  en: ('A'..'Z').to_a
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Alfabet

Returns a new instance of Alfabet.



8
9
10
11
# File 'lib/freshmind/alfabet.rb', line 8

def initialize(options = {})
  @lang  = options.fetch(:lang) { :en }
  @order = options.fetch(:order){ :ordered }
end

Instance Attribute Details

#langObject (readonly)

Returns the value of attribute lang.



2
3
4
# File 'lib/freshmind/alfabet.rb', line 2

def lang
  @lang
end

#orderObject (readonly)

Returns the value of attribute order.



2
3
4
# File 'lib/freshmind/alfabet.rb', line 2

def order
  @order
end

Instance Method Details

#listObject



13
14
15
16
17
# File 'lib/freshmind/alfabet.rb', line 13

def list
  res = (LETTERS[lang] * 2)[0, 40]
  res = res.sample(res.size) if order.to_sym == :random
  res
end