class CS::Message

Public Class Methods

new(url) click to toggle source

attr_accessor *@vars

# File lib/csapi/messages.rb, line 60
def initialize(url)
  @url = url
  @fetched = false
end

Public Instance Methods

date() click to toggle source
# File lib/csapi/messages.rb, line 75
def date
  fetch unless @fetched
  Date.parse(@date)
end
fetch() click to toggle source
# File lib/csapi/messages.rb, line 65
def fetch
  req = HTTP.get(@url)
  @data = JSON.parse req.body
end
is_sender?() click to toggle source
# File lib/csapi/messages.rb, line 85
def is_sender?
  fetch unless @fetched
  @user_is_sender
end
method_missing(meth) click to toggle source
# File lib/csapi/messages.rb, line 90
def method_missing meth
  if vars.include? meth
    fetch unless @fetched
    @data[meth.to_s]
  else
    raise ArgumentError.new
  end
end
to_h() click to toggle source
# File lib/csapi/messages.rb, line 70
def to_h
  fetch unless @fetched
  @data
end
unread?() click to toggle source
# File lib/csapi/messages.rb, line 80
def unread?
  fetch unless @fetched
  @is_unread
end