Class: DomesticateMonkeys::Snapshot
- Inherits:
-
Object
- Object
- DomesticateMonkeys::Snapshot
- Defined in:
- lib/domesticate_monkeys/constants/snapshot.rb
Instance Attribute Summary collapse
-
#all_tracks ⇒ Object
readonly
The Snapshot’s data storage serves as a basis for other classes, such as View (which provides insight into the data storage), Report (which provides aggregate information about your application) and TrackExport (which generates a JSON file).
-
#filtered_tracks ⇒ Object
readonly
The Snapshot’s data storage serves as a basis for other classes, such as View (which provides insight into the data storage), Report (which provides aggregate information about your application) and TrackExport (which generates a JSON file).
-
#multi_tracks ⇒ Object
readonly
The Snapshot’s data storage serves as a basis for other classes, such as View (which provides insight into the data storage), Report (which provides aggregate information about your application) and TrackExport (which generates a JSON file).
Instance Method Summary collapse
- #filter_no_methods ⇒ Object
-
#initialize ⇒ Snapshot
constructor
A new instance of Snapshot.
- #inspect ⇒ Object
- #select_multi_tracks ⇒ Object
- #sort_tracks(tracks) ⇒ Object
Constructor Details
#initialize ⇒ Snapshot
Returns a new instance of Snapshot.
14 15 16 17 18 |
# File 'lib/domesticate_monkeys/constants/snapshot.rb', line 14 def initialize @all_tracks = $DOMESTICATE_MONKEYS_TRACKS @filtered_tracks = filter_no_methods @multi_tracks = select_multi_tracks end |
Instance Attribute Details
#all_tracks ⇒ Object (readonly)
The Snapshot’s data storage serves as a basis for other classes, such as View (which provides insight into the data storage), Report (which provides aggregate information about your application) and TrackExport (which generates a JSON file).
12 13 14 |
# File 'lib/domesticate_monkeys/constants/snapshot.rb', line 12 def all_tracks @all_tracks end |
#filtered_tracks ⇒ Object (readonly)
The Snapshot’s data storage serves as a basis for other classes, such as View (which provides insight into the data storage), Report (which provides aggregate information about your application) and TrackExport (which generates a JSON file).
12 13 14 |
# File 'lib/domesticate_monkeys/constants/snapshot.rb', line 12 def filtered_tracks @filtered_tracks end |
#multi_tracks ⇒ Object (readonly)
The Snapshot’s data storage serves as a basis for other classes, such as View (which provides insight into the data storage), Report (which provides aggregate information about your application) and TrackExport (which generates a JSON file).
12 13 14 |
# File 'lib/domesticate_monkeys/constants/snapshot.rb', line 12 def multi_tracks @multi_tracks end |
Instance Method Details
#filter_no_methods ⇒ Object
20 21 22 |
# File 'lib/domesticate_monkeys/constants/snapshot.rb', line 20 def filter_no_methods @all_tracks.filter { _1.include?(".") || _1.include?("#") } end |
#inspect ⇒ Object
34 35 36 37 38 39 |
# File 'lib/domesticate_monkeys/constants/snapshot.rb', line 34 def inspect # Overwrite default behaviour, which returns – and thus often prints – # the values of the object's set instance variables, which is enormous # in the case of @all_tracks and @multi_tracks. to_s end |
#select_multi_tracks ⇒ Object
24 25 26 27 |
# File 'lib/domesticate_monkeys/constants/snapshot.rb', line 24 def select_multi_tracks multis = @filtered_tracks.select { |_method, track| track.count > 1 } sort_tracks(multis) end |
#sort_tracks(tracks) ⇒ Object
29 30 31 32 |
# File 'lib/domesticate_monkeys/constants/snapshot.rb', line 29 def sort_tracks(tracks) sorted_array = tracks.sort_by { |_method, track| -track.count } sorted_hash = sorted_array.map { |_method, track| { _method => track } }.inject(&:merge) end |