Sha256: b3d6898553208918589cae3e8e94f47253c9d8d25230c232dedb81123d0cb302

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

module CodewarsApi
  class KataInfo
    include Common

    def initialize(id)
      @response = RequestHelper.get("#{CodewarsApi::API_URL}/code-challenges/#{id}")
      ResponseChecker.check_errors(@response)
    end

    def id
      @response.to_h['id']
    end

    def name
      @response.to_h['name']
    end

    def slug
      @response.to_h['slug']
    end

    def category
      @response.to_h['category']
    end

    def published_at
      @response.to_h['publishedAt']
    end

    def approved_at
      @response.to_h['approvedAt']
    end

    def languages
      @response.to_h['languages']
    end

    def url
      @response.to_h['url']
    end

    def rank
      @response.to_h['rank']
    end

    def created_at
      @response.to_h['createdAt']
    end

    def creater_username
      @response.to_h['createdBy'].andand['username']
    end

    def creater_url
      @response.to_h['createdBy'].andand['url']
    end

    def approver_username
      @response.to_h['approvedBy'].andand['username']
    end

    def approver_url
      @response.to_h['approvedBy'].andand['url']
    end

    def description
      @response.to_h['description']
    end

    def total_attempts
      @response.to_h['totalAttempts']
    end

    def total_completed
      @response.to_h['totalCompleted']
    end

    def total_stars
      @response.to_h['totalStars']
    end

    def vote_score
      @response.to_h['voteScore']
    end

    def tags
      @response.to_h['tags']
    end

    def contributors_wanted
      @response.to_h['contributorsWanted']
    end

    def unresolved_issues
      @response.to_h['unresolved'].andand['issues']
    end

    def unresolved_suggestions
      @response.to_h['unresolved'].andand['suggestions']
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
codewars_api-0.4.2 lib/codewars_api/kata_info.rb
codewars_api-0.4.1 lib/codewars_api/kata_info.rb
codewars_api-0.4.0 lib/codewars_api/kata_info.rb