class MastodonStreaming

Attributes

num[RW]
stream[RW]

Public Class Methods

new(stream, url) click to toggle source
# File lib/legion/mastodon.rb, line 40
def initialize(stream, url)
    @stream = stream
    @url    = url
    @num    = 0
end

Public Instance Methods

HomeTimeline(window, list) click to toggle source
# File lib/legion/mastodon.rb, line 46
def HomeTimeline(window, list)
    @stream[@num].user() do |toot|
        message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
        list.insert('0', "#{toot.account.display_name} さん : #{message.text}")
    end
end
LocalTimeline(window, list) click to toggle source
# File lib/legion/mastodon.rb, line 60
def LocalTimeline(window, list)
    @stream[@num].firehose() do |toot|
        puts @url[@num]
        if toot.uri.to_s =~ /#{@url[@num]}/ then
            message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
            list.insert('0', "#{toot.account.display_name} さん : #{message.text}")
        end
    end
end
PublicTimeline(window, list) click to toggle source
# File lib/legion/mastodon.rb, line 53
def PublicTimeline(window, list)
    @stream[@num].firehose() do |toot|
        message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
        list.insert('0', "#{toot.account.display_name} さん : #{message.text}")
    end
end
Timeline(timeline) click to toggle source
# File lib/legion/mastodon.rb, line 70
def Timeline(timeline)

    case timeline[0]

    when 1
        self.HomeTimeline(timeline[1], timeline[2])

    when 2
        self.LocalTimeline(timeline[1], timeline[2])

    when 3
        self.PublicTimeline(timeline[1], timeline[2])
    end
end