Class: Theoj::Journal
- Inherits:
-
Object
- Object
- Theoj::Journal
- Defined in:
- lib/theoj/journal.rb
Instance Attribute Summary collapse
-
#alias ⇒ Object
Returns the value of attribute alias.
-
#data ⇒ Object
Returns the value of attribute data.
-
#doi_prefix ⇒ Object
Returns the value of attribute doi_prefix.
-
#launch_date ⇒ Object
Returns the value of attribute launch_date.
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #current_issue ⇒ Object
- #current_volume ⇒ Object
- #current_year ⇒ Object
-
#initialize(custom_data = {}) ⇒ Journal
constructor
A new instance of Journal.
- #paper_doi_for_id(paper_id) ⇒ Object
- #paper_id_from_issue(review_issue_id) ⇒ Object
- #reviews_repository_url(issue_id = nil) ⇒ Object
- #year_volume_issue_for_date(d) ⇒ Object
Constructor Details
#initialize(custom_data = {}) ⇒ Journal
Returns a new instance of Journal.
12 13 14 |
# File 'lib/theoj/journal.rb', line 12 def initialize(custom_data = {}) set_data custom_data end |
Instance Attribute Details
#alias ⇒ Object
Returns the value of attribute alias.
9 10 11 |
# File 'lib/theoj/journal.rb', line 9 def alias @alias end |
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/theoj/journal.rb', line 5 def data @data end |
#doi_prefix ⇒ Object
Returns the value of attribute doi_prefix.
6 7 8 |
# File 'lib/theoj/journal.rb', line 6 def doi_prefix @doi_prefix end |
#launch_date ⇒ Object
Returns the value of attribute launch_date.
10 11 12 |
# File 'lib/theoj/journal.rb', line 10 def launch_date @launch_date end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/theoj/journal.rb', line 8 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/theoj/journal.rb', line 7 def url @url end |
Instance Method Details
#current_issue ⇒ Object
24 25 26 |
# File 'lib/theoj/journal.rb', line 24 def current_issue data[:current_issue] || (1 + ((Time.new.year * 12 + Time.new.month) - (launch_year * 12 + launch_month))) end |
#current_volume ⇒ Object
20 21 22 |
# File 'lib/theoj/journal.rb', line 20 def current_volume data[:current_volume] || (Time.new.year - (launch_year - 1)) end |
#current_year ⇒ Object
16 17 18 |
# File 'lib/theoj/journal.rb', line 16 def current_year data[:current_year] || Time.new.year end |
#paper_doi_for_id(paper_id) ⇒ Object
33 34 35 |
# File 'lib/theoj/journal.rb', line 33 def paper_doi_for_id(paper_id) "#@doi_prefix/#{paper_id}" end |
#paper_id_from_issue(review_issue_id) ⇒ Object
28 29 30 31 |
# File 'lib/theoj/journal.rb', line 28 def paper_id_from_issue(review_issue_id) id = "%05d" % review_issue_id "#{@alias}.#{id}" end |
#reviews_repository_url(issue_id = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/theoj/journal.rb', line 37 def reviews_repository_url(issue_id=nil) reviews_url = "https://github.com/#{data[:reviews_repository]}" if issue_id reviews_url += "/issues/" + issue_id.to_s end reviews_url end |
#year_volume_issue_for_date(d) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/theoj/journal.rb', line 45 def year_volume_issue_for_date(d) d = Date.parse(d) if d.is_a? String year = d.year volume = year - (launch_year - 1) issue = (1 + ((year * 12 + d.month) - (launch_year * 12 + launch_month))) [year, volume, issue] end |