class GNUSocial::Timeline

Represents Timeline or group of notices.

Public Class Methods

from_json(json) click to toggle source

Creates a Timeline object from JSON response.

# File lib/gsruby.rb, line 198
def self.from_json(json)
    notices = []
    JSON.parse(json).each do |notice|
        notices.push(Notice.new(notice))
    end
    Timeline.new(notices)
end
new(notices) click to toggle source

Creates a new Timeline object

# File lib/gsruby.rb, line 207
def initialize(notices)
    @notices = notices
end

Public Instance Methods

newest_notice() click to toggle source

Return the most recent notice on this timeline.

# File lib/gsruby.rb, line 223
def newest_notice
    @notices[0]
end
notice(index) click to toggle source

Return the notice with the given index on this timeline.

# File lib/gsruby.rb, line 212
def notice(index)
    return 'Index must be a integer' unless index.is_a?(Fixnum)
    (0..size-1).cover?(index) ? @notices[index] : 'Bad index'
end
notices() { |n| ... } click to toggle source

Calls the given block for each notice on this timeline.

# File lib/gsruby.rb, line 233
def notices
    return "Need a block" unless block_given?
    @notices.each do |n|
        yield(n)
    end
end
oldest_notice() click to toggle source

Returns the less recent notice on this timeline.

# File lib/gsruby.rb, line 228
def oldest_notice
    @notices[-1]
end
size() click to toggle source

Returns the number of notices on this timeline.

# File lib/gsruby.rb, line 218
def size
    @notices.size
end