Socialmetrica/Socialmetrica.package/TwitterUser.class/instance/collectMessages.byTimeSpanSplits..st

17 lines
731 B
Smalltalk

accessing
collectMessages: aBlock byTimeSpanSplits: anInteger
| timespans spanLabels messagesByTimespan |
timespans := aBlock value timeSpansOf: anInteger.
spanLabels := (timespans collect: [ :timeSpan | | start end |
start := (timeSpan start dayOfMonth) asString, ' ', ((timeSpan start monthName) asString copyFrom:1 to: 3).
end := (timeSpan end dayOfMonth) asString, ' ', ((timeSpan end monthName) asString copyFrom:1 to: 3).
start, '→ ', end
]) asArray.
messagesByTimespan := OrderedDictionary new.
spanLabels doWithIndex: [:label :i |
messagesByTimespan
at: label
put: (aBlock value messages select: [ :message |
(timespans at: i) includes: (message created asDateAndTime)])
].
^ messagesByTimespan