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.
14 15 16 17 |
# File 'lib/zold/hexnum.rb', line 14 def initialize(num, length) @num = num @length = length end |
Class Method Details
Instance Method Details
#to_i ⇒ Object
19 20 21 |
# File 'lib/zold/hexnum.rb', line 19 def to_i @num end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/zold/hexnum.rb', line 23 def to_s format("%0#{@length}x", @num).gsub(/^\.{2}/, 'ff') end |