From fa310a1821f399df9e79e0e643fec2b33a97ba61 Mon Sep 17 00:00:00 2001 From: Chris Mytton Date: Thu, 23 Feb 2017 15:09:04 +0100 Subject: [PATCH] Add YARD documentation the PersonCard class We want to eventually document all classes in the app, so this is another step in that direction. --- lib/person_cards.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/person_cards.rb b/lib/person_cards.rb index 404710a7b..12f7546ae 100644 --- a/lib/person_cards.rb +++ b/lib/person_cards.rb @@ -1,44 +1,65 @@ # frozen_string_literal: true +# A single person card on the term table page class PersonCard + # @param person [Everypolitician::Popolo::Person] the person this card represents + # @param term [Everypolitician::LegislativePeriod] the term the card is for def initialize(person:, term:) @person = person @term = term end + # URL for a proxied version of the person's image + # @return [String] def proxy_image 'https://mysociety.github.io/politician-image-proxy' \ "/#{legislature.country.slug}/#{legislature.slug}/#{id}/140x140.jpeg" end + # EveryPolitician UUID for this person + # @return [String] def id person.id end + # Primary display name for this person + # @return [String] def name person.name end + # URL for the unproxied version of the person's image + # @return [String] def image person.image end + # Social media information about this person + # @return [Array] def social Section::Social.new(person).data end + # Biographical information about this person + # @return [Array] def bio Section::Bio.new(person).data end + # Contact details for this person + # @return [Array] def contacts Section::Contacts.new(person).data end + # Identifiers for this person + # @return [Array] def identifiers Section::Identifiers.new(person, top_identifiers: top_identifiers).data end + # List of memberships this person holds in the current term + # @return [Array] def memberships person.memberships.where(legislative_period_id: term.id) end