class Hipmost::Hipchat::PostRepository
Attributes
name_index[RW]
posts[RW]
Public Class Methods
for_room(room)
click to toggle source
# File lib/hipmost/hipchat/post_repository.rb, line 13 def self.for_room(room) new(room).tap(&:load) end
new(room)
click to toggle source
# File lib/hipmost/hipchat/post_repository.rb, line 17 def initialize(room) @room = room @path = $path.join("rooms", room.id.to_s, "history.json") @posts = [] end
Public Instance Methods
file_data()
click to toggle source
# File lib/hipmost/hipchat/post_repository.rb, line 37 def file_data return if !File.exists?(@path) File.read(@path) end
load(data = file_data)
click to toggle source
# File lib/hipmost/hipchat/post_repository.rb, line 23 def load(data = file_data) return if !File.exists?(@path) json = JSON.load(data) json.each do |post_obj| next if post_obj.key?("NotificationMessage") next if post_obj.key?("GuestAccessMessage") next if post_obj.key?("ArchiveRoomMessage") next if post_obj.key?("TopicRoomMessage") post = post_obj["UserMessage"] @posts << Post.new(post, @room) end end