Module: Ppp
- Defined in:
- lib/ppp.rb,
lib/ppp/version.rb,
lib/ppp/card/base.rb
Defined Under Namespace
Modules: Card Classes: Generator
Constant Summary collapse
- VERSION =
'1.0.1'
- @@ALPHABETS =
{ :conservative => '!#%+23456789:=?@ABCDEFGHJKLMNPRSTUVWXYZabcdefghijkmnopqrstuvwxyz', :aggressive => '!"#$%&\'()*+,-./23456789:;<=>?@ABCDEFGHJKLMNOPRSTUVWXYZ[\]^_abcdefghijkmnopqrstuvwxyz{|}~' }
Class Method Summary collapse
-
.card(type, *args) ⇒ Object
A
Card
of the given type. -
.code_generator(key, opts = {}) ⇒ Ppp::Generator
With the given SHA-256 key.
-
.default_alphabets ⇒ Hash{Symbol => String}
The default alphabets.
-
.key_from_string(str) ⇒ Object
A SHA-256 digest of the given string.
-
.random_key ⇒ Object
A random SHA-256 key.
Class Method Details
.card(type, *args) ⇒ Object
Returns a Card
of the given type.
34 35 36 37 38 39 40 41 |
# File 'lib/ppp.rb', line 34 def card type, *args case type when :html then return Card::Html.new *args when :xml then return Card::Xml.new *args when :plain then return Card::Plain.new *args end raise ArgumentError.new( "%s is not a valid printer style." % style ) end |
.code_generator(key, opts = {}) ⇒ Ppp::Generator
Returns with the given SHA-256 key.
16 17 18 |
# File 'lib/ppp.rb', line 16 def code_generator key, opts={} Generator.new key, opts end |
.default_alphabets ⇒ Hash{Symbol => String}
Returns the default alphabets.
44 45 46 |
# File 'lib/ppp.rb', line 44 def default_alphabets @@ALPHABETS end |
.key_from_string(str) ⇒ Object
Returns a SHA-256 digest of the given string.
22 23 24 |
# File 'lib/ppp.rb', line 22 def key_from_string str Digest::SHA256.new.update( str ).to_s end |
.random_key ⇒ Object
Returns a random SHA-256 key.
27 28 29 |
# File 'lib/ppp.rb', line 27 def random_key Cppp.random_key end |