class GithubEventsExport::Event
Wrapper around a GitHub Event
developer.github.com/v3/activity/events
Attributes
event_data[R]
Public Class Methods
all(client)
click to toggle source
# File lib/github_events_export/event.rb, line 9 def self.all(client) client.user_events(client.user.id).map { |e| new(e) } end
new(event_data)
click to toggle source
# File lib/github_events_export/event.rb, line 13 def initialize(event_data) @event_data = event_data end
Public Instance Methods
save()
click to toggle source
# File lib/github_events_export/event.rb, line 17 def save save! if changed? end
save!()
click to toggle source
# File lib/github_events_export/event.rb, line 21 def save! File.write(filename, to_json) end
Private Instance Methods
changed?()
click to toggle source
# File lib/github_events_export/event.rb, line 29 def changed? return true unless persisted? Digest::MD5.hexdigest(to_json) != Digest::MD5.hexdigest(File.read(filename)) end
filename()
click to toggle source
# File lib/github_events_export/event.rb, line 40 def filename "#{event_data.id}.json" end
persisted?()
click to toggle source
# File lib/github_events_export/event.rb, line 36 def persisted? File.exist?(filename) end
to_json()
click to toggle source
# File lib/github_events_export/event.rb, line 44 def to_json event_data.to_h.to_json end