Class: MSR::Tracks
- Inherits:
-
Object
- Object
- MSR::Tracks
- 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
-
#==(other) ⇒ Boolean
Compare two sets of tracks for equality.
-
#empty? ⇒ Boolean
Whether or not all tracks are empty.
- #initialize ⇒ Object constructor
-
#reverse ⇒ MSR::Tracks
Reverse the direction of the tracks, returning a new object.
-
#reverse! ⇒ MSR::Tracks
Reverse the direction of the tracks, in place.
-
#track1 ⇒ MSR::Track
The first track on the card.
-
#track2 ⇒ MSR::Track
The second track on the card.
-
#track3 ⇒ MSR::Track
The third track on the card.
-
#tracks ⇒ Array<MSR::Track>
All tracks on the card, as an array.
Constructor Details
#initialize ⇒ Object
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.
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.
8 9 10 |
# File 'lib/msr/tracks.rb', line 8 def empty? tracks.all?(&:empty?) end |
#reverse ⇒ MSR::Tracks
Reverse the direction of the tracks, returning a new object.
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.
14 15 16 17 18 |
# File 'lib/msr/tracks.rb', line 14 def reverse! @tracks = reverse.tracks self # return ourself, just for convenience end |
#track1 ⇒ MSR::Track
The first track on the card.
7 |
# File 'ext/msr/tracks.c', line 7 static VALUE msr_tracks_get_track1(VALUE self); |
#track2 ⇒ MSR::Track
The second track on the card.
13 |
# File 'ext/msr/tracks.c', line 13 static VALUE msr_tracks_get_track2(VALUE self); |
#track3 ⇒ MSR::Track
The third track on the card.
19 |
# File 'ext/msr/tracks.c', line 19 static VALUE msr_tracks_get_track3(VALUE self); |
#tracks ⇒ Array<MSR::Track>
All tracks on the card, as an array.
25 |
# File 'ext/msr/tracks.c', line 25 static VALUE msr_tracks_get_tracks(VALUE self); |