Class: Key::Key
- Inherits:
-
Object
- Object
- Key::Key
- Defined in:
- lib/key/base.rb
Overview
Key
Virtual base class for keys
Instance Attribute Summary (collapse)
-
- (Object) key
readonly
Returns the value of attribute key.
Instance Method Summary (collapse)
-
- (Object) condensed
condensed.
-
- (Key) initialize(key)
constructor
A new instance of Key.
-
- (Object) length
length.
- - (Object) to_s
Constructor Details
- (Key) initialize(key)
Returns a new instance of Key
19 20 21 22 23 24 25 26 27 |
# File 'lib/key/base.rb', line 19 def initialize(key) raise ArgumentError if key.class != String and key.class != Fixnum if key.class == Fixnum then if key < 0 or key > 26 then raise RangeError end end @key = key.to_s.upcase end |
Instance Attribute Details
- (Object) key (readonly)
Returns the value of attribute key
17 18 19 |
# File 'lib/key/base.rb', line 17 def key @key end |
Instance Method Details
- (Object) condensed
condensed
35 36 37 |
# File 'lib/key/base.rb', line 35 def condensed @key.condensed end |
- (Object) length
length
41 42 43 |
# File 'lib/key/base.rb', line 41 def length @key.length end |
- (Object) to_s
29 30 31 |
# File 'lib/key/base.rb', line 29 def to_s @key end |