$segments_arrayref = split_with_entities($text, $entities_hashref)

Splits the given $text with the "entities" and returns the split segments.

$text is a string to be split. $entities_hashref is a hash-ref which has the same stucture as Twitter Entities. Each entity object annotates a part of $text with such information as linked URLs, mentioned users, mentioned hashtags, etc. If $entities_hashref doesn't conform to the said structure, it is ignored.

The return value $segments_arrayref is an array-ref of "segment" objects. A "segment" is a hash-ref containing a part of $text and the entity object (if any) attached to it. Note that $segments_arrayref has segments that no entity is attached to. $segments_arrayref is sorted, so you can assemble the complete $text by concatenating all the segments.

Any entity object is required to have indices field, which is an array-ref of starting and ending indices of the text part. The ending index must be greater than or equal to the starting index. If an entitiy object does not meet this condition, that entity object is ignored.

Except for indices, all fields in entity objects are optional.

Text ranges annotated by entity objects must not overlap. In that case, the result is undefined.

A segment hash-ref has the following fields.

text

Substring of the $text.

start

Starting index of the segment in $text.

end

Ending index of the segment in $text.

type

Type of the entity. If the segment has no entity attached, it is undef.

entity

Attached entity object. If the segment has no entity attached, it is undef.

It croaks if $text is undef.

$future = future_of($invocant, $method, %args)

This function executes $invocant->$method(%args), which is supposed to be a callback-style method. Before the execution, callback field in %args is overwritten, so that the result of the $method can be obtained from $future.

To use future_of(), the $method must conform to the following specification. (Most of BusyBird::Timeline's callback-style methods follow this specification)

In the above example, statuses are imported from three different RSS feeds using BusyBird::Input::Feed. Because BusyBird::Timeline rejects duplicate statuses, the above code adds only new and unread statuses to $main_timeline.

However, if update rates of the three feeds are different, it's possible for old statuses to re-appear in $main_timeline as new statuses. This is because BusyBird::Timeline has limited capacity for storing statuses.

Suppose the example1 and example2 update quickly whereas example3's update rate is very slow. At first, $main_timeline keeps all statuses from the three feeds. After a while, the $main_timeline will be filled with statuses from example1 and example2, and at a certain point, statuses from example3 will be discarded because they are too old. After that, $main_timeline->add( $input->parse_url('http://example3.com/feed.rss') ) imports the same statuses just discarded, but $main_timeline now recognizes them as new because they are no longer in $main_timeline. So those old statuses from example3 will re-appear as unread.