Method: Ppp::Card::Base#passcode

Defined in:
lib/ppp/card/base.rb

#passcode(cell) ⇒ String #passcode(row, column) ⇒ String

Overloads:

  • #passcode(cell) ⇒ String

    Returns the passcode in the given cell.

    Parameters:

    • cell (String)

      A cell ID. example: 10B

    Returns:

    • (String)

      the passcode in the given cell

  • #passcode(row, column) ⇒ String

    Returns the passcode in the given row and column.

    Parameters:

    • row (Fixnum)

      the row of the passcode to return

    • column (String)

      the column of the passcode to return

    Returns:

    • (String)

      the passcode in the given row and column



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/ppp/card/base.rb', line 75

def passcode *args
  case args.size
  when 1
    match = @@ROW_COL_PATTERN.match( args.first )
    raise ArgumentError.new( @@ERROR_BAD_ROW_COL % args.first ) unless match
    row = match[1]
    col = match[2]
  when 2
    (row, col) = args
  else
    raise ArgumentError.new( @@ERROR_WRONG_NUM_ARGS % ['1 or 2', args.size] )
  end

  col_offset = col.ord - @@FIRST_COLUMN.ord
  row_offset = row.to_i - 1

  offset = row_offset * passcodes_per_line + col_offset
  offset = card_offset + offset
  @generator.passcode offset
end