Class: EaSSL::Serial
- Inherits:
-
Object
- Object
- EaSSL::Serial
- Defined in:
- lib/eassl/serial.rb
Overview
- Author
-
Chris Andrews ([email protected])
- Copyright
-
Copyright © 2011 Chris Andrews
- License
-
Distributes under the same terms as Ruby
Instance Attribute Summary collapse
-
#next ⇒ Object
readonly
Returns the value of attribute next.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Serial
constructor
A new instance of Serial.
- #issue_serial ⇒ Object
- #save! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Serial
Returns a new instance of Serial.
8 9 10 11 |
# File 'lib/eassl/serial.rb', line 8 def initialize( = {}) @next = [:next] @path = [:path] end |
Instance Attribute Details
#next ⇒ Object (readonly)
Returns the value of attribute next.
7 8 9 |
# File 'lib/eassl/serial.rb', line 7 def next @next end |
Class Method Details
.load(serial_file_path) ⇒ Object
13 14 15 16 |
# File 'lib/eassl/serial.rb', line 13 def self.load(serial_file_path) hex_string = (File.read(serial_file_path)) self.new(:next => Integer("0x#{hex_string}"), :path => serial_file_path) end |
Instance Method Details
#issue_serial ⇒ Object
27 28 29 30 |
# File 'lib/eassl/serial.rb', line 27 def issue_serial @next = @next + 1 @next - 1 end |
#save! ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/eassl/serial.rb', line 18 def save! if @path hex_string = sprintf("%04X", @next) File.open(@path, 'w') do |io| io.write "#{hex_string}\n" end end end |