class Shangrila::Sana

Public Class Methods

new(hostname = 'api.moemoe.tokyo') click to toggle source
# File lib/shangrila/sana.rb, line 10
def initialize(hostname = 'api.moemoe.tokyo')
  @url = "http://#{hostname}/anime/v1/twitter"
end

Public Instance Methods

follower_history(account, end_date = nil) click to toggle source

@param [String] account データ取得対象のアニメTwitter公式アカウント @param [int] end_date 検索対象の終了日時 where update_at < end_date) @return [Array] フォロワー数と更新日時のハッシュの配列

# File lib/shangrila/sana.rb, line 25
def follower_history(account, end_date = nil)
  response = nil
  if end_date.nil?
    response = HTTPClient.get(sprintf('%s/follower/history?account=%s', @url, account))
  else
    response = HTTPClient.get(sprintf('%s/follower/history?account=%s&end_date=%d', @url, account, end_date))
  end

  JSON.load(response.body)
end
follower_history_daily(account, days = nil) click to toggle source

/anime/v1/twitter/follower/history/daily @param [String] account データ取得対象のアニメTwitter公式アカウント @param [int] days 取得日数 @return [Array] フォロワー数と更新日時のハッシュの配列

# File lib/shangrila/sana.rb, line 40
def follower_history_daily(account, days = nil)
  response = HTTPClient.get(sprintf('%s/follower/history/daily?account=%s&days=%s', @url, account, days))

  JSON.load(response.body)
end
follower_status(accounts, is_to_json = true) click to toggle source

@param [Array] accounts データ取得対象のアニメTwitter公式アカウント @param [boolean] is_to_json JSONをRubyHashにして返すかどうか @return [Hash] アカウント群をキーとしたハッシュ

# File lib/shangrila/sana.rb, line 17
def follower_status(accounts, is_to_json = true)
  response = HTTPClient.get(sprintf('%s/follower/status?accounts=%s', @url, accounts.join(',')))
  is_to_json ? JSON.load(response.body) : response.body
end