Class: Zold::Hexnum
- Inherits:
-
Object
- Object
- Zold::Hexnum
- Defined in:
- lib/zold/hexnum.rb
Overview
A hex num
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(num, length) ⇒ Hexnum
constructor
A new instance of Hexnum.
- #to_i ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(num, length) ⇒ Hexnum
Returns a new instance of Hexnum.
31 32 33 34 |
# File 'lib/zold/hexnum.rb', line 31 def initialize(num, length) @num = num @length = length end |
Class Method Details
Instance Method Details
#to_i ⇒ Object
36 37 38 |
# File 'lib/zold/hexnum.rb', line 36 def to_i @num end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/zold/hexnum.rb', line 40 def to_s format("%0#{@length}x", @num).gsub(/^\.{2}/, 'ff') end |