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

[patch:lib] Modify entity instance method aliases #34

Merged
merged 3 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ author = paper.authors.first
author.name
#=> "F. Gebhard"

author.affiliations?
author.affiliated?
#=> true
author.affiliations
#=> ["ILL Grenoble, France"]
Expand Down
5 changes: 2 additions & 3 deletions lib/arx/entities/author.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ class Author
# @return [Array<String>]
has_many :affiliations, Cleaner, tag: 'affiliation', parser: :clean

# @!method affiliations?
# Whether or not the author has any affiliations.
# @return [Boolean]
def affiliations?
def affiliated?
!affiliations.empty?
end

inspector :name, :affiliations?, :affiliations
inspector :name, :affiliated?, :affiliations
end
end
19 changes: 8 additions & 11 deletions lib/arx/entities/paper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ def url
@id
end

# @!method last_updated
# @!method updated_at
# The date that the paper was last updated.
# @return [DateTime]
element :last_updated, DateTime, tag: 'updated'
alias_method :updated_at, :last_updated
element :updated_at, DateTime, tag: 'updated'

# @!method publish_date
# @!method published_at
# The original publish/submission date of the paper.
# @return [DateTime]
element :publish_date, DateTime, tag: 'published'
alias_method :published_at, :publish_date
element :published_at, DateTime, tag: 'published'

# @!method title
# The title of the paper.
Expand All @@ -53,19 +51,18 @@ def url
# The primary category of the paper.
# @return [Category]
element :primary_category, Category, tag: 'primary_category'
alias_method :primary_subject, :primary_category
alias_method :category, :primary_category

# @!method categories
# The categories of the paper.
# @return [Array<Category>]
has_many :categories, Category, tag: 'category'
alias_method :subjects, :categories

# Whether the paper is a revision or not.
# @note A paper is a revision if {last_updated} differs from {publish_date}.
# @note A paper is a revision if {updated_at} differs from {published_at}.
# @return [Boolean]
def revision?
@publish_date != @last_updated
@published_at != @updated_at
end

# @!method summary
Expand Down Expand Up @@ -157,7 +154,7 @@ def revision?
inspector *%i[
id url title summary authors
primary_category categories
publish_date last_updated revision?
published_at updated_at revision?
comment? comment
journal? journal
pdf? pdf_url
Expand Down