Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YARD documentation the PersonCard class #15614

Merged
merged 2 commits into from
Feb 23, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/person_cards.rb
Original file line number Diff line number Diff line change
@@ -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<PersonCard::Section::CardLine>]
def social
Section::Social.new(person).data
end

# Biographical information about this person
# @return [Array<PersonCard::Section::CardLine>]
def bio
Section::Bio.new(person).data
end

# Contact details for this person
# @return [Array<PersonCard::Section::CardLine>]
def contacts
Section::Contacts.new(person).data
end

# Identifiers for this person
# @return [Array<PersonCard::Section::CardLine>]
def identifiers
Section::Identifiers.new(person, top_identifiers: top_identifiers).data
end

# List of memberships this person holds in the current term
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current is a little too ambiguous here, I fear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I had the same thought while doing 5000246! Have fixed that in fc67a72.

# @return [Array<EveryPolitician::Popolo::Membership>]
def memberships
person.memberships.where(legislative_period_id: term.id)
end
Expand Down