Class: SMPTool::Filename

Inherits:
Object
  • Object
show all
Defined in:
lib/smp_tool/filename.rb

Overview

Converts RADIX-50 <-> ASCII filenames.

Constant Summary collapse

FN_BASE_LENGTH =
6
FN_EXT_LENGTH =
3
ASCII_DOT_POS =

Dot position in the printable ASCII filename.

6
DEF_SEP_CHR =

Separation character.

"."

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Filename

Returns a new instance of Filename.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/smp_tool/filename.rb', line 16

def initialize(options = {})
  _validate_options(options)

  if options.key?(:radix50)
    _handle_radix_input(options)
  elsif options.key?(:ascii)
    _handle_ascii_input(options)
  else
    raise ArgumentError, "Either :radix50 or :ascii must be provided"
  end

  _make_ascii_name
end

Instance Attribute Details

#asciiObject (readonly)

Returns the value of attribute ascii.



8
9
10
# File 'lib/smp_tool/filename.rb', line 8

def ascii
  @ascii
end

#radix50Object (readonly)

Returns the value of attribute radix50.



8
9
10
# File 'lib/smp_tool/filename.rb', line 8

def radix50
  @radix50
end

Instance Method Details

ASCII filename with a dot to separate extension.



33
34
35
# File 'lib/smp_tool/filename.rb', line 33

def print_ascii(sep_chr = DEF_SEP_CHR)
  @ascii.insert(ASCII_DOT_POS, sep_chr)
end