Sha256: b0e6a0a7b89d01ea488023a61663e0f1999d8b2c2c02196656f1484dc13cb7d9

Contents?: true

Size: 757 Bytes

Versions: 1

Compression:

Stored size: 757 Bytes

Contents

module Linguist
  module Models
    require 'linguist/models/project'

    class Projects

      PROJECT_URL = '/projects'

      def initialize(client)
        @client   = client
      end

      def create(title)
        @client.post(PROJECT_URL, :project => {:title => title})
      end

      def all
        return @projects if defined? @projects
        @projects = {}
        response = JSON.parse @client.get(PROJECT_URL).to_s
        response["projects"]["members"].each do |member|
          project = Linguist::Models::Project.new(@client, member["link"][0]["href"])
          @projects[member["title"]] = project
        end
        @projects
      end

      def [](project_title)
        return all[project_title]
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
linguist_ruby-0.0.2 lib/linguist/models/projects.rb