Sha256: dba83de2545fe63e35b307de837bca026c3b6ddef8d52889561d61ddf47fdb35

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

# encoding: utf-8
module Ayadn
  class FileOps

    def self.save_post(resp)
      File.write(Settings.config[:paths][:posts] + "/#{resp['data']['id']}.json", resp['data'].to_json)
    end

    def self.save_message(resp)
      File.write(Settings.config[:paths][:messages] + "/#{resp['data']['id']}.json", resp['data'].to_json)
    end

    def self.save_followings_list(list)
      fg = get_users(list)
      File.write(Settings.config[:paths][:lists] + "/followings.json", fg.to_json)
    end

    def self.save_followers_list(list)
      fr = get_users(list)
      File.write(Settings.config[:paths][:lists] + "/followers.json", fr.to_json)
    end

    def self.save_muted_list(list)
      mt = get_users(list)
      File.write(Settings.config[:paths][:lists] + "/muted.json", mt.to_json)
    end

    def self.download_url(name, url)
      file = CNX.get_response_from(url)
      File.write(Settings.config[:paths][:downloads] + "/#{name}", file)
    end

    def self.old_ayadn?
      Dir.exist?(Dir.home + "/ayadn/data")
    end

    private

    def get_users(list)
      h = {}
      list.each {|k,v| h[k] = { username: v[0], name: v[1] }}
      h
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ayadn-1.3.2 lib/ayadn/fileops.rb
ayadn-1.3.1 lib/ayadn/fileops.rb
ayadn-1.3.0 lib/ayadn/fileops.rb
ayadn-1.2.10 lib/ayadn/fileops.rb
ayadn-1.2.9 lib/ayadn/fileops.rb