Sha256: 03d9e20f14570e7fe0f23c910d2e474270789955bf01e7351d8cbf1f7657de69

Contents?: true

Size: 552 Bytes

Versions: 1

Compression:

Stored size: 552 Bytes

Contents

module Fappu
  class Tag

    attr_accessor :name, :url
    URL = "https://api.fakku.net/tags"

    def initialize args
      args.each do |k,v|
        instance_variable_set("@#{k}",v) unless v.nil?
      end
    end

    def self.list
      response = JSON.parse( URI.parse(URL).read )
      arr = response["tags"]

      arr.collect do |tag|
        self.new(tag_parameters(tag))
      end
    end

    private

    def self.tag_parameters(tag)
      params = {
        name: tag["tag_name"],
        url: tag["tag_url"]
      }
    end


  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fappu-1.0.0 lib/fappu/tag.rb