Class: MSR::Tracks

Inherits:
Object
  • Object
show all
Defined in:
lib/msr/tracks.rb,
ext/msr/tracks.c

Overview

Represents (up to) three tracks from a magnetic stripe card.

Constant Summary collapse

MAX_TRACKS =
INT2NUM(MSR_MAX_TRACKS)

Instance Method Summary collapse

Constructor Details

#initializeObject

Instance Method Details

#==(other) ⇒ Boolean

Compare two sets of tracks for equality. Two sets are said to be equal if all of their corresponding pairs are equal.

Parameters:

  • other (Tracks)

    the tracks to compare to

Returns:

  • (Boolean)

    true if the two are equal, false otherwise



24
25
26
27
# File 'lib/msr/tracks.rb', line 24

def ==(other)
  return unless other.is_a?(self.class)
  track1 == other.track1 && track2 == other.track2 && track3 == other.track3
end

#empty?Boolean

Whether or not all tracks are empty.

Returns:

  • (Boolean)

    true if all tracks are empty, false otherwise



8
9
10
# File 'lib/msr/tracks.rb', line 8

def empty?
  tracks.all?(&:empty?)
end

#reverseMSR::Tracks

Reverse the direction of the tracks, returning a new object.

Returns:



31
# File 'ext/msr/tracks.c', line 31

static VALUE msr_tracks_reverse(VALUE self);

#reverse!MSR::Tracks

Reverse the direction of the tracks, in place.

Returns:



14
15
16
17
18
# File 'lib/msr/tracks.rb', line 14

def reverse!
  @tracks = reverse.tracks

  self # return ourself, just for convenience
end

#track1MSR::Track

The first track on the card.

Returns:



7
# File 'ext/msr/tracks.c', line 7

static VALUE msr_tracks_get_track1(VALUE self);

#track2MSR::Track

The second track on the card.

Returns:



13
# File 'ext/msr/tracks.c', line 13

static VALUE msr_tracks_get_track2(VALUE self);

#track3MSR::Track

The third track on the card.

Returns:



19
# File 'ext/msr/tracks.c', line 19

static VALUE msr_tracks_get_track3(VALUE self);

#tracksArray<MSR::Track>

All tracks on the card, as an array.

Returns:



25
# File 'ext/msr/tracks.c', line 25

static VALUE msr_tracks_get_tracks(VALUE self);